Skip to content

Problem occurs when player stops on the slope after climbing #3

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

Open
YeapseRinkado opened this issue Sep 8, 2015 · 2 comments
Open

Comments

@YeapseRinkado
Copy link

Thank you for your brilliant tutorial, but I've found a problem after watching and practicing the episode 5, it is that if the player stop on a slope after climbing, it may slip a bit after a while, especially when the angle of the slope is really large.
image
the first picture shows the raycast of the player when it just finished climbing
image
the second picture shows the raycast of of the player after a while

I think it may caused by the gravity? Because the gravity applies on the player every frame.

So have you found this problem either? Or maybe there is something wrong with my code?I use Unity version 5, too
Thanks.

Sorry about my poor English XD.

@YeapseRinkado
Copy link
Author

I finally find the problem is the acceleration time of the velocityX, when player stop on a slope, the velocityX is not zero, and it may cause some unexpected problems, so I change the code like this:
velocity.x = targetVelocityX == 0 ? targetVelocityX :Mathf.SmoothDamp(velocity.x, targetVelocityX, ref velocityXSmoothing, (controller.collisions.below)?accelerationTimeGrounded:accelerationTimeAirborne);

and it works, now the player can stop steady on a slope after climbing or jumping :)
And thank you for your tutorial again :)

@llafuente
Copy link

can you please send a PR with the fix to https://github.com/llafuente/unity-platformer

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