- Home /
transform.Rotate not working beyond 90 / 270 degs with RigidBodies (bug?)
I have a GameObject that is a Kinematic Rigidbody.
I'm trying to rotate this object (with iTween) on the X axis. IT WILL NOT ROTATE BEYOND 90 degrees.
It works when I remove the RigidBody but doesn't work with it on.
With the RigidBody NOT ATTACHED - it will automatically adjust the Y & Z values by 180 each - thus making it work just fine.
When the RigidBody IS ATTACHED it doesn't do this automatic adjustment and instead the X axis is clamped between 270 - 90.
This is both true when trying to adjust the value in the Inspector, as well as through code (using transform.Rotate).
This most certainly has to be a bug. Is there a workaround anybody knows of? Thanks.
Answer by Eric5h5 · Nov 23, 2014 at 06:53 PM
It's not a bug. Unity uses quaternions for rotation, and there's more than one valid way to convert a rotation to euler angles. For example, (0, 0, 0) and (180, 180, 180) are the same rotation. This is why the docs say not to use one axis from eulerAngles; you need to read the entire rotation. In the above example, if you read eulerAngles.x and saw it was 0, then read it again and it was 180, you might think it's "wrong", but it's not, in the context of the entire rotation.
Thanks for your response.
I am using transform.Rotate to perform my rotations. When my eulerAngles read (90, 0, 0) or (270, 0, 0), transform.Rotate DOES NOT $$anonymous$$OVE THE$$anonymous$$.
The code is effectively rotating by small amounts every frame, like so:
transform.Rotate ( new Vector3(1f, 0, 0), Space.World ); // called every update.
this is just a summary of what the code is actually doing. I'm using iTweens RotateBy function.
I've gone digging deeper and found another interesting... thing. When your x values are at 90 or at 270, they seem to "snap" or "stick" to this value. Unless you rotate by an increment of about 3 or higher, it will remain stuck.
This seems to be the heart of the problem...! Is this a known issue? Any workarounds? Thanks.
Answer by Jignesh G. · Nov 23, 2014 at 06:31 PM
Had you tried `transform.localEulerAngles? this might resolve your problem.
Thanks.
Your answer
Follow this Question
Related Questions
How i can equal 2 Tranform Rotations? 1 Answer
Quaternions acting up 1 Answer
Rotating a certain axis offsets the other ones? 1 Answer
if & Quaternion 2 Answers
How to always rotate clockwise 1 Answer