how to get object rotation?
Seems like a simple question, but regardless of how I approach the problem, I always end up with a non linear output. I'm looking for an output which will go from 0 to 1 (or 0 to 360) before resetting, or basically any linear interpretation of steadily rotating object, however when I use any of the below methods, it always increases steadily, reaches a point, and then decreases steadily.
For example, using Debug.Log(transform.rotation.eulerAngles.x);
will output between 270 and 90 only, increasing/decreasing steadily before changing direction. I'm using transform.Rotate(1, 0, 0);
to get my steady rotation and this seems to be working fine. Where have I gone wrong in attempting to get it to output linearly? (no change in direction). The object starts at 0,0,0 rotation. I have tried:
transform.rotation.eulerAngles.x
transform.rotation.x
along with local rotation vairants of both. Nothing seems to work. Any advice?
Answer by Daedalus216 · Jun 08, 2017 at 12:08 AM
The issue was actually pretty straightforward. I hadn't noticed the y and z axis had switched to 180. This is a horrible system in unity.
However incase anyone finds it helpful, my solution was simply making a local Vector3 with whatever rotation i want with x,y and z respectively, setting the transform.rotation to be that vector3 in Update, and then referencing Vector3 whenever i needed to know the angle. Hope this helps!
Your answer
Follow this Question
Related Questions
Simple Rotate Script won't work! 2 Answers
Rotation Issue 0 Answers
Multiple rotations make a mess! 0 Answers
how do I rotate an object without affecting later rotation? 0 Answers
Drag - Rotate 0 Answers