Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

falling-off-ledges prevention (mc) feature #2563

Closed
wants to merge 3 commits into from

Conversation

nihal111
Copy link
Member

Contains

Potential falling-off-ledges prevention feature.

An extension to PR #2544 and issue #1075.

As of now I have a basic check for preventing the character to fall down any step larger than 0.35f. But if I keep pushing the character off the ledge, at one point the state becomes non-grounded i.e state.isGrounded() == false and the game hangs for a frame and the character "appears to" fall off a height (I know because, the landing sound of character fall, is played) landing at the same position with a loss of health.

Could use some help in fixing that.

@GooeyHub
Copy link
Member

Hooray Jenkins reported success with all tests good!

@GooeyHub
Copy link
Member

Hooray Jenkins reported success with all tests good!

@skaldarnar
Copy link
Member

Thanks for your work @nihal111. As discussed on Slack, the whole movement-related code could use some good refactoring. I think we might be able to attack this with some joint work by you, @portokaliu (maybe @xrtariq2594 and others).

I'd be happy to merge a minimal working version of this fix before. It seems like you moved some code and added comments here and there. Strip all that down to a bare minimum for this PR and add the additional work and documentation to the refactoring work.

Copy link
Member

@skaldarnar skaldarnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep forgetting how complicated diffs can look if you move stuff around and change if-elses. Left some comments to look into, and a slightly longer comment on the general approach I'd like to take for this part of the code.

@@ -94,6 +94,40 @@ public KinematicCharacterMover(WorldProvider wp, PhysicsEngine physicsEngine) {
physics = physicsEngine;
}

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moving this method does not have substantial benefit at this point (could apply it later, though)

@@ -355,8 +355,10 @@ private MoveResult move(final Vector3f startPosition, final Vector3f moveDelta,
if (moveDelta.y < 0 || steppedUpDist > 0) {
float dist = (moveDelta.y < 0) ? moveDelta.y : 0;
dist -= steppedUpDist;
// Returns true if bottom is hit at current position.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment should better be a javadoc for moveDown() imho

Vector3f to = new Vector3f(pos.x, pos.y - 0.35f, pos.z);
SweepCallback callback = collider.sweep(pos, to, VERTICAL_PENETRATION_LEEWAY, -1f);
if (callback.hasHit()) {
state.getPosition().set(moveResult.getFinalPosition());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of setting the state here, the moveResult (the movement to perform) should be adjusted to prevent falling off the ledge. this probably needs some better structuring of the whole walk method to get a better overview of things.

@rzats rzats removed the in progress label Oct 25, 2016
@rzats rzats added the Category: Gameplay Content Requests, Issues and Changes targeting gameplay mechanics and content label Nov 3, 2016
@oniatus
Copy link
Contributor

oniatus commented May 11, 2017

Is this still in progress/an issue? I did a short test with a 3-block tower on a flat surface with ladders on one side and got no falling sound when hitting the ground or walking on the top block.

there were some other oddities though:

  • jumping on a ladder moved the player upwards, i expected him to fall down/backwards or not jump at all
  • When climbing on top of the block, the player moves a bit higher than needed, then falls a bit (no sound though)
  • compared to minecraft, the controls on the ladder are dependent on the view direction. In Minecraft, you can view downwards and press w until you reach the top. In Terasology, you have to view above the horizon which makes it hard to spot the point where your character moves above the edge.
    If it's out of scope of the PR i can move this to a separate feature request issue :)

@GooeyHub
Copy link
Member

Hooray Jenkins reported success with all tests good!

@portokaliu
Copy link
Contributor

@oniatus I think this one is stuck alongside movement refactoring (which would change all of what you mentioned :) )

@oniatus
Copy link
Contributor

oniatus commented Jan 21, 2018

I think after this period of inactivity we can close this one for now. Feel free to reuse some of the ideas or reopen it as needed.
We also can continue any discussion about the feature on #1075 .

@oniatus oniatus closed this Jan 21, 2018
@Cervator
Copy link
Member

Also linking to #2573

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Gameplay Content Requests, Issues and Changes targeting gameplay mechanics and content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants