- Home /
Prevent the rotation
I have a character which has some animations
and I am using for rotation
rigidbody.AddTorque(new Vector3(0, rotationFactor * Input.GetAxis("Horizontal"), 0));
and for forward movement
rigidbody.AddForce(rigidbody.transform.TransformDirection(Vector3.forward * Input.GetAxis("Vertical") * speedFactor));
I have two animations on it, one for when it is idle and one for when it is running, the problem is that these animation cause a slight rotation change of the character, even in the idle case. I want to have rotation only because of the AddTorque
, is it any way to prevent the rotation that is caused by the animation?
I found out that the problem is not the animation, the problem probably is in the function that is moving the character, when I am trying to move it forward it is also rotating on the left side, I can not understand why. Any idea?
Answer by JeffreyD · Apr 05, 2014 at 02:47 PM
It sounds as if you need to constrain the rotation as you move. I just searched for "contraining rotation" and found this link.http://answers.unity3d.com/questions/549019/constraints-on-rotation-axis-in-c.html
There are many others. Hope it helps.
Your answer
![](https://koobas.hobune.stream/wayback/20220613141959im_/https://answers.unity.com/themes/thub/images/avi.jpg)