-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
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. |
There was a problem hiding this 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; | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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.
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:
|
Hooray Jenkins reported success with all tests good! |
@oniatus I think this one is stuck alongside movement refactoring (which would change all of what you mentioned :) ) |
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. |
Also linking to #2573 |
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.