- Home /
 
How to lock the rotation of an object on all axes?
How do I lock the rotation of an object via script?
Thanks in advance!
               Comment
              
 
               
              What kind of object. $$anonymous$$aybe:
 rigidbody.freezeRotation = true;
 
                  Or maybe you want to modify the constraints:
 rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraings.FreezeRotationZ;
 
                 Answer by ExtremePowers · Nov 04, 2014 at 04:51 PM
Couldn't you just do:
 var LockedRotation : Quarternion;
 var Lock : boolean;
 
 if (Lock) {
     if (LockedRotation == null) {
         LockedRotation = transform.rotation;
     }
     transform.rotation = LockedRotation
 } else {
     if (LockedRotation != null) {
         LockedRotation = null;
     }
 }
 
              Your answer
 
             Follow this Question
Related Questions
Creating a multiple part turret what locks onto certain axis. 4 Answers
Unity touchpad not working to rotate an object 1 Answer
Lock Z rotation to 0 2 Answers
How do I keep the angle of a box? 1 Answer
Forcing a rotation point 2 Answers