Rotation is broken
I have a simple demo project where my "player object" has a rotation of 0, 45, 0 (xyz).
When I use code to extract this it shows -2.912, 45, -1.969
I use the code: transform.rotation.eulerAngles;
Why isn't this shown correctly. I use the rotation for launching a projectile, so it's a bit weird having the direction of the projectiles turn quicker than my placeholder object
Answer by tormentoarmagedoom · Jul 18, 2018 at 07:53 AM
Good day.
1st, rotation is not broken, MAybe you dont understand why this hapens, but ists you, not Unity.
Most probably the object is child of another object? This rotation is the local rotation, not the global.
Or maybe some code or collision is moving it
Answer by Sgt_Spike · Jul 18, 2018 at 01:10 PM
Hi there. Extending on from tormentoarmagedoom's answer, it is probably because you have a parent object of the object you are trying to rotate. I have had issues with rotation and positioning in the past, and that was my issue. Perhaps you could try using LocalEulerAngles in your code instead of just EulerAngles, so your code will look something like this 'transform.rotation.localEulerAngles;'. See if that works and hopefully it will solve your problem! :D
Your answer
Follow this Question
Related Questions
Rotating game object 1 Answer
My rotation is not the same in inspector as it is in the scirpt 0 Answers
Cant stop object/ridgidbody from rotating 2 Answers
3D, Rotate gun towards mouse 0 Answers
Cannon rotation clamping 0 Answers