- Home /
How to freeze position x and z on rigidbody(both!)
I was trying to use RigidbodyConstraints to freeze a cube's x and z position. I then used Debug.Log(rigidbody.constraints) to print the constraints. When I ran the game, It printed only(I checked all the Debug.LOg stuff in the console) position x, the one I set to freeze second. Is there a way to freeze both?
Answer by pickle chips · Jul 26, 2013 at 04:14 AM
It literally says in the documentation how, and even uses it in the example:
http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-constraints.html
you just put | (the bitwise or operator) inbetween the two constraints
The doc link specifies only Rotation, not Position and nothing seems to work if you change "Rotation" to "Position", so I'm still not getting the expected results either.
jg2115, were you able to figure it out?
You can use FreezePosition ins$$anonymous$$d of FreezeRotation, it ended up working for me.
Your answer
Follow this Question
Related Questions
Disabling rigidbody constraints in code - Freeze Position, Rotation etc 7 Answers
iTween moveby constrained by rigidbody constraints in Unity 5 2 Answers
Attempt to disable constraints using RigidbodyConstraints.None has no effect 0 Answers
Freeze gameobject with a collision 1 Answer
holding position 1 Answer