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

Moving from walkable slope to wall causes a bounce and stick to wall #43

Open
Stevepunk opened this issue Nov 29, 2015 · 4 comments
Open

Comments

@Stevepunk
Copy link

Moving from walkable slope to wall causes a bounce and stick to wall. I doubt this is intended.
Each time the player moved against a wall from a slope he bounced up instead of standing still.

He does this even if the minimumSpeedToMoveUpSlipperySlope is set to a large number to stop the player from attempting to climb slopes that he is not able to.

Everything else works great even with procedurally generated meshes/colliders!
Awesome work indeed!

@Stevepunk
Copy link
Author

To resolve this I added an extra grounded check when encountering a wall:
(assuming that if we're grounded and not moving sideways then we also don't want to move vertically either)

    // These mean we can't progress forward. Either a wall or a slope
    if (HasFlag(CollidedSurface.LeftWall) &&
        _velocity.x < 0 &&
        _collidedNormals[DIRECTION_LEFT] == Vector2.right ||
        HasFlag(CollidedSurface.RightWall) &&
        _velocity.x > 0 &&
        _collidedNormals[DIRECTION_RIGHT] == Vector2.left)
    {
        if (IsGrounded())
        {
            velocity = Vector2.zero;
        }
        else
        {
            _velocity.x = 0;
        }   
    }

This resolved the problem for most speeds, but when travelling at fast speeds with a slow computer I found that I had to increase Environment Check Distance from 0.02f to 0.1f.

On even slower computers it may need to be increased more or there may be a more efficient solution..

@llafuente
Copy link
Contributor

I see you have a fork. Can you please commit an example scene and the fix so We can take look.

@cjddmut
Copy link
Owner

cjddmut commented Nov 30, 2015

Is this when encountering a wall or a steep slope?

Also, given that this is in FixedUpdate then it shouldn't matter if the computer is fast or slow.

@pixellykyle
Copy link

I've also seen this problem and tried the fix from Mr-Sheen a few posts up. It seems to fix the issue in most cases but if the character hits a vertical wall while running up a slope at too high a speed he'll do a little jump/bounce.

All the slopes in my game are 45 degrees, with all other colliders being perfectly horizontal or vertical.

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

4 participants