How do I unfreeze z rotation in a script and then freeze it again
I have the z rotation on my character constrained by default, so how do I unfreeze it inside of a script? Also how to I refreeze it again?
Answer by sokolllll89 · Sep 19, 2017 at 12:58 PM
rb2d.freezeRotation = true;
rb2d.freezeRotation = false;
or
rb2d.constraints = RigidbodyConstraints2D.FreezeRotation;
rb2d.constraints = RigidbodyConstraints2D.None;
It's important to note here if you are using a 3D Rigidbody you will need to use the RigidbodyConstraints.FreezeRotationZ
enum rather then RigidbodyConstraints.FreezeRotation
otherwise it will lock rotation on all axis a list of the enums can be found in the documentation (For 3D Rigidbodies, For 2D Rigidbodies ).
Your answer
Follow this Question
Related Questions
Cannot get rigidbody constraint to unfreeze 1 Answer
I have a problem with constraining rotation of rigid bodies connected to hinge joints. 0 Answers
How to enable rigidbody constraints only at start? 2 Answers
Rigidbody 2D Freeze Position X bug? 0 Answers
Error CS0201 when trying to change RigidbodyConstraints 1 Answer