- Home /
Limit the rotation of an object
I'd like to limit the rotation of a specific object. It's 2.5D, so the object still has to tilt up and tilt down, but I would like it to not tilt sideways.
I've tried a number of solutions, and all ended in the object not having accurate physics, as in it glitching up and down while trying to navigate slopes.
EulerAngles are all somehow linked up, as if X moves, for example, then Y gets modified too.
Are there any solutions?
just a quick question, do you have a rigidbody on the object you are trying to rotate?
Answer by whydoidoit · Mar 23, 2014 at 12:09 PM
You should be using the freeze rotation options to stop it turning around the axes you don't want. http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-freezeRotation.html
Euler Angles are not used internally to store rotations, it uses Quaternions. Several combinations of euler angles can represent the same actual rotation (one of their most significant limitations) so it is quite possible that they will appear to change dramatically as an object rotates. See this for rotations http://unitygems.com/quaternions
Your answer
Follow this Question
Related Questions
How to properly reference a Euler? 1 Answer
Rotate and eulerAngles don't work together ?? 2 Answers
When applying a 90 degree rotation to Euler Angles, it is over/undershooting sometimes.. 2 Answers
Rotate an object a set angle over time? (C#) 1 Answer
screw changes direction of screwdriver 0 Answers