Hello, is there a way to check our current slope angle? I am using default character controller. I would like my character to behave differently on certain angles.
Example: On 0-30 degrees my character use default “walk” animation, but on higher degrees (like stairs) it uses other animation.
There are some ways. But they depend on how you made a collider for a stairs. For example, if it is simply inclined plane (write on CSharp):
private float myAng = 0.0f;
void Update() {
//Here move your controller and fr slope angle:
if(myAng < 30) {
//Simple move animation
} else {
//Stairs animation
}
}
void OnControllerColliderHit(ControllerColliderHit hit) {
myAng = Vector3.Angle(Vector3.up, hit.normal); //Calc angle between normal and character
}
And second. If you designated each step of a stair, it is necessary to calculate pregoing and current positions. And then also to calculate a angle. But between character and its movement. I hope that it will help you.