- Home /
Can I limit the rotation of an Object on an axis between a Negative and Positive value?
Hellow,
As asked in the title, is there a way to limit the rotation of an object between a negative and positive value?
Exemple:
Limit rotation from -90 (270) to 90. Thus making it from 270 to 0 to 90. And not 270 to 0 to 90.
Thank you.
Answer by Oninji · Oct 21, 2010 at 09:11 PM
I control my rotation through a value. Convert the value to eulerangle. This permit to limit between a negative and positive value. It also avoid the gimbleLock problem.
Answer by spinaljack · Oct 17, 2010 at 09:33 PM
You can use a hinge joint limit or you can use Vector3.angle
For hinge joint you can set a min angle of -90 and a max angle of 90 but it's physics based so wont work for scripted movement.
Finding the angle between a standard direction and the current direction via scripts and stopping its movement or snapping to the limit is the other option.
Your answer
![](https://koobas.hobune.stream/wayback/20220613075943im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
rotating an object only on z-axis help - c# 2 Answers
Need help with rotation script. 1 Answer
Orbit Collision Axis 0 Answers
Instantiate a rotated object 4 Answers