can you send me a sample project of the issue?? send it as a private message.
I traced the problem to the following line in Unity’s default ThirdPerson controller script:
move = Vector3.ProjectOnPlane(move, m_GroundNormal);
This uses the ground normal, which would apparently explain why it cancels movement on an incline in certain directions, hence it throws the animator into the idle clip, which slows player to a crawl sometimes and also interrupts my footstep code since that code has to check whether the idle animation is beginning (otherwise an extra footstep plays after player has stopped moving as the animator transitions into the idle animation).
i don’t like using animator speed… it has some draw backs if you are not managing it 100%…
animations for me is no more than a “representation” everything is controlled on rigidbody velocity… so your issue has nothing to do with physics… your animations is what controlling the speed and causing issues.
I said it was caused by the ProjectOnPlane() function (not physics), which takes the slope into account and there’s clearly something going wrong with that. That code was just the default Unity code in the built-in controller. m_GroundNormal is just hitInfo.normal (the normal of the collider hit by the downward raycast that checks what’s underneath the player). So ProjectOnPlane() clearly isn’t working when the ramp is rotated toward certain directions.
Posting on a necro because I found a solution. I did it in unity 3D but it should still work for 2D too.
Add an empty GameObject to your player named Ground Detector and place it at the bottom of the player. Use a serialized variable called groundDetector to hold this empty GameObject. Add this to the player script:
RaycastHit hitPoint;
bool isGrounded = Physics.Raycast(groundDetector.position, Vector3.down, out hitPoint, 0.1F);
if (isGrounded)
transform.position = hitPoint.point + new Vector3(0,1,0);