Answer the question
In order to leave comments, you need to log in
How to disable axis rotation?
I have an object whose rotation along the z axis I need to allow from time to time, I can’t figure out how to correctly refer to the Rigidbody in the script in order to change this parameter.
To make it easier to understand, I will give an example of changing the Is Kinematic parameter through a script
. Something like this, is it possible to do the same with rotation lock?
GetComponent<Rigidbody>().IsKinematic = true;
Answer the question
In order to leave comments, you need to log in
Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
//запретить
rb.constraints = RigidbodyConstraints.FreezeRotationZ
//разрешить
rb.constraints = RigidbodyConstraints.None;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question