- Home /
What could be the reason
Hi friends,
Whenever I rotate an object in Unity the values are different when I print using Debug.Log and in the inspector.
There might be a possibility that in CG, the rotation happens in counter clockwise direction. Means, rotating left actually increases rotation, and towards decreases. The problem comes in decreasing rotation. It doesn't give negative values.
That is when I rotate towards +ve right direction, it decreases from 360 - the amount of rotation. Giving positive values.
But when I want to limit an angle with limits, this is giving problems. How can solve this? What is exact reason behind this?
Please suggest some ideas.
Answer by BenouKat · Apr 06, 2015 at 10:50 AM
It's because you are checking the EulerAngles and not the Quaternion, which the values can be managed by Unity for some reasons explained here : http://answers.unity3d.com/questions/48609/whats-the-difference-between-rotation-eulerangles.html
If you want to check an angle I would suggest to check this with the Vector3.Angle for exemple and check if your object and the direction vector you want are close. You can also look to Quaternion.LookRotation method.
Your answer
Follow this Question
Related Questions
Change input direction to camera's forward 0 Answers
Basic 2D movement C# - Key presses cancel eachother out 4 Answers
Creating Hint Vector 1 Answer
Clamping Vector3 2 Answers