- Home /
GameObject Rotation Jumps in value
Hi all,
In my app I have a rotating dial which allows the user to touch the indented "handle" and drag around it to move the dial in a clockwise / counter-clockwise direction. I am using a helper GameObject as my rotation object, and want to use the increasing or decreasing rotation value to adjust the BPM (beats per minute). Trouble is, when watching the helper's rotation value changing in the inspector, it appears to jump all over the place, rather than going from 0 - 359. The value seems to jump when the handle reaches the 12 o'clock and 6 o'clock position. The dial appears to work just fine visually, but the rotation value makes it impossible for me to use it as a way of judging an increment or a decrement of the main value.
Importantly, i'm using Transform.LookAt() to make the rotation helper look at where I am touching and dragging. Maybe there's a better way to go about this?
If anyone could advise me on this i'd be so grateful!
Thanks
Mat
You need to tell us exactly how you're getting the rotation values, otherwise we can't help you. Post some code (not all of it, just the relevant bits).
Answer by runevision · Jul 08, 2010 at 11:22 AM
In Unity rotations are stored as quaternions, which is a different representation than euler angles, even though euler angles is what is shown in the inspector. In the conversions between euler angles to quaternions and back, the numbers can change but the actual orientation remain the same. For example (0, 0, 370) could change to (0, 0, 10), which is identical rotations but with different representations.
If you want to have full control over the angles, you need to store the angle values yourself, for example in a Vector3, or in a flat if you only need to control one of them. You then manipulate these angle values and convert them when needed to quaternions, but you never read back from the quaternions. This way you will never get undesired changes in the angle representations.
Your answer
Follow this Question
Related Questions
How Can I Stop Rotation From This Script? 0 Answers
smooth transform look at with space self rotation 0 Answers
Rotation with multiple objects 1 Answer
Make object only rotate in 90 degree increments 0 Answers
Bullet not moving towards player 3 Answers