Question by
scyt_ · Mar 16 at 07:42 PM ·
rotationprogrammingrotation axis
X Rotation randomly jumps to 90?
Hey! I wanna open a door by slowy rotation the Z axis to -150. So I wrote this code snippet that happens when the player presses E in front of the door:
if (opening == true) { if (transform.rotation.eulerAngles.z > -150) { transform.rotation = Quaternion.Euler(new Vector3(0, 0, transform.rotation.eulerAngles.z - 1)); } }
And the Z axis get's rotated correctly, but the X axis jumps to 90? And I don't know why.
Also the Z axis doesnt stop rotation at -150, it's just endlessly spinning.
I can't just use an animation because that door will exist multiple times in every level.
What did I do wrong? I'm a pretty newbie
Comment