- Home /
Is 360° the same as 0°?
I have an object that I want to rotate around a parent object. So it would be something like this (see picture).
So I'll need to rotate the parent in order for the object to rotate around it. If i set the initial rotation to be 'InitRot' and I set the new rotation to be 'InitRot + 30', the object will rotate clockwise with 30 degrees. Now if I want the object to rotate 30 degress to the left, I would do 'InitRot + 330' thinking that it will rotate counterclockwise, but it will not, it still rotates clockwise. Now the question is, can I change this by saying: 'InitRot = InitRot + 360', so that the object will be in the same position, but will have a different value. So that then when I set the new rotation to 'InitRot - 30', the object will rotate counterclockwise.
Or could I just do 1) new rotation = Initrot + 30 for clockwise rotations 2) new rotation = Initrot - 30 for counterclockwise rotations
Tyvm!!
Basicly yes, but in certen cases it also isn't. If you are in editor and you fill in 360° at rotation while 0° was previus then it dosen't matter.
Answer by Anxo · Jan 08, 2015 at 04:45 PM
It all depends on what method you are using to rotate.
You do not have to rotate the parent if you do not want to, you could use http://docs.unity3d.com/ScriptReference/Transform.RotateAround.html
Or you could use transform.eulerAngles in connection with a http://docs.unity3d.com/ScriptReference/Vector3.RotateTowards.html which would allow you to specify the specific rotation you wish to achieve and allow the system to pick the shortest path.
You could use tarnsform.Rotate or transform.rotation in which case you would have to use Quaternions which can be more complicated to deal with.
I recommend transform.eulerAngles with RotateTwoards, for easiest and most predictable results.
Hey, I don't have much time right now to test these out, but I think one of your methods will most certainly solve the problem! Thank you so much!
Answer by Owen-Reynolds · Jan 08, 2015 at 05:26 PM
Yes. Your logic is correct. For example, +330 is the same as -30 for (Unity) rotations.
The only time this doesn't work is if your code is doing other odd stuff. For example, some hidden part of your code is snapping it to -180 to 180.
I think most odd errors are comparing rotations with an "off by 360" issue. If you set rotation to 10, then set it to 371 next frame, it will correctly appear to rotate 1 degree. But if you Lerp it from 10 to 371, it will go through all the numbers, making a full spin plus 1 degree.
Reading a value back from a rotation can do this: you set to +190, then read it (eulerAngle) back and get -170. If you just add 1 and set it again, that's fine. +191 and -169 are still the same. But, again, sometimes you then try to move that -170 up to a new +191. Or you increase until it gets to 200 (which will never happen.)
Your answer
Follow this Question
Related Questions
How do I call a function containing a while loop, inside the update function? 2 Answers
How can i rotate the aircraft elevator around the yellow axis up and down ?? as shown in the pic 0 Answers
Reversing rotation back to zero 0 Answers
Object wont rotate in the opposite direction 1 Answer
Strange rotation pattern. 0 Answers