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

Can't ascend low hanging one-way platforms, possible fix included #43

Closed
astrobread opened this issue Jan 4, 2015 · 3 comments
Closed

Comments

@astrobread
Copy link

If a one-way platform is placed just overhead of the character, they cannot jump completely through it.

To recreate place a one-way platform just above the player. They don't need to be touching, but it has to be close enough so that the initial jump velocity will collide them in the first frame of the jump.

Expected result is that the player passes through the one-way platform, then lands on it after the jump is complete. Observed result is that the player travels most of the way through the platform, then their jump ends much sooner than expected and they fall back to where they started.

onewayjumpsnap

This issue can be resolved by modifying this line in CharacterController2D.moveVertically:

if (isGoingUp && !collisionState.wasGroundedLastFrame)
   mask &= ~oneWayPlatformMask;

If you remove the wasGroundedLastFrame condition the platform behaves as expected. Was this condition included to allow one-way platforms with slopes? Or is it for something else I'm not aware of?

@prime31
Copy link
Owner

prime31 commented Jan 4, 2015

That change was indeed a way to allow walking up a sloped one-way platform.
I'll have to give it some though to see if there is a clean way to handle
both or if sloped one-way platform support should be a boolean
configuration (seems like it is not very common).

Mike

On Sat, Jan 3, 2015 at 4:09 PM, astrobread notifications@github.com wrote:

If a one-way platform is placed just overhead of the character, they
cannot jump completely through it.

To recreate place a one-way platform just above the player. They don't
need to be touching, but it has to be close enough so that the initial jump
velocity will collide them in the first frame of the jump.

Expected result is that the player passes through the one-way platform,
then lands on it after the jump is complete. Observed result is that the
player travels most of the way through the platform, then their jump ends
much sooner than expected and they fall back to where they started.

[image: onewayjumpsnap]
https://cloud.githubusercontent.com/assets/8303758/5604181/606c6696-9371-11e4-8000-2a6e8aedf0da.PNG

This issue can be resolved by modifying this line in
CharacterController2D.moveVertically:

if (isGoingUp && !collisionState.wasGroundedLastFrame)
mask &= ~oneWayPlatformMask;

If you remove the wasGroundedLastFrame condition the platform behaves as
expected. Was this condition included to allow one-way platforms with
slopes? Or is it for something else I'm not aware of?


Reply to this email directly or view it on GitHub
#43.

@astrobread
Copy link
Author

This is just from eyeballing the code so I could be missing something, but I don't think this change would impact one-way platform slopes.

There are no meaningful collisions with one-way platforms while ascending in MoveVertically(). It only casts rays from the top of the collider in this situation, so anything it hits has nothing to do with what you're walking across. When ascending, this function's only job is to prevent you from cracking your head against solid platforms.

What makes sloped one-way platforms work is already inside MoveHorizontally(), which uses similar logic to detect slopes from either kind of platform. Whereas the grounded check inside MoveVertically() only seems to prevent jumping onto one-way platforms

@prime31
Copy link
Owner

prime31 commented Jan 5, 2015

You might be right. I'll do some rest with and without the check and make sure all is well.

On Jan 4, 2015, at 4:50 PM, astrobread notifications@github.com wrote:

This is just from eyeballing the code so I could be missing something, but I don't think this change would impact one-way platform slopes.

There are no meaningful collisions with one-way platforms while ascending in MoveVertically(). It only casts rays from the top of the collider in this situation, so anything it hits has nothing to do with what you're walking across. When ascending, this function's only job is to prevent you from cracking your head against solid platforms.

What makes sloped one-way platforms work is already inside MoveHorizontally(), which uses similar logic to detect slopes from either kind of platform. Whereas the grounded check inside MoveVertically() only seems to prevent jumping onto one-way platforms


Reply to this email directly or view it on GitHub.

@prime31 prime31 closed this as completed Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants