- Home /
can't get desired rotation angles
while an object is rotating if it rotates to a certain angle ex: ( -50 and 50) I want the scene to change. I've gotten the object to rotate, I've gotten the scenes/UI to update, but I can't find any method or float that'll execute if the rotation is == to my desired angle.
My Code:
if (transform.eulerAngles.z > 50f) { GameOver(GameIsOver = true); } else if (transform.eulerAngles.z < -50f) { GameOver(GameIsOver = true); }
Answer by Quatnu · May 31 at 07:26 PM
eualerAngles are not values from -180 to 180. Instead, it's from 0 to 360. I would recommend a solution something like this.
if (transform.eulerAngles.z > 50 && transform.eulerAngles.z < 310)
{
GameOver(GameIsOver = true);
}
else if (transform.eulerAngles.z > 310)
{
GameOver(GameIsOver = true);
}
(The second condition: 360 - 50 = 310)
using this code and doing transform.rotation.eulerAngles.z helped me thank you a lot. I was stuck on this for a long time. Thank you.
Your answer
Follow this Question
Related Questions
Why Is Rotation Different For RectTransform? 0 Answers
How to set a single-axis rotation and not change the others axes 1 Answer
Why is my object's local x rotation not going past 90 degrees? 1 Answer
My Obstacle Rotations Are Not Correct 0 Answers
Rotation problem while dynamically changing animations 2 Answers