2DPlatformer-Tutorial icon indicating copy to clipboard operation
2DPlatformer-Tutorial copied to clipboard

Problem occurs when player stops on the slope after climbing

Open YeapseRinkado opened this issue 10 years ago • 2 comments

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 avatar Sep 08 '15 12:09 YeapseRinkado

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 :)

YeapseRinkado avatar Sep 08 '15 13:09 YeapseRinkado

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

llafuente avatar Apr 04 '16 13:04 llafuente