- Home /
Why can't check for rotation
I'm making a clock puzzle where you have to put the correct time in the clock to proceed but every time the rotations of the clock face are correct the trigger does work. I've found that it has to do with the angle tester lines but I can't figure out why.
private void OnTriggerEnter(Collider other)
{ if (big_hand.transform.rotation.eulerAngles.x > -100) && (big_hand.transform.rotation.eulerAngles.x < -80 && little_hand.transform.rotation.eulerAngles.x > -40 && little_hand.transform.rotation.eulerAngles.x < -60)
{ SceneManager.LoadScene("SampleScene") }
}
I believe your little hand comparisons need swapped. You are saying if the little hand is outside the range -60 to -40 not within.
Answer by Namey5 · Feb 24, 2020 at 05:50 AM
EulerAngles will always be in a range of [0,360]. Even though in the inspector you can set negative values, that is more for user convenience and they aren't actually stored that way internally. You will either need to change your check values into that range or remap the actual angles into a range of [-180,180], i.e;
Vector3 angles = transform.rotation.eulerAngles; //[0,360]
for (int i = 0; i < 3; i++)
angles[i] = (angles[i] + 180f) % 360f - 180f; //[-180,180]
Your answer
![](https://koobas.hobune.stream/wayback/20220612223848im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem when checking a Quaternion Eulerangle axis 1 Answer
Clamping rotation doesn't work when local axis is different from global 0 Answers
Rotation Lock 0 Answers
Checking if statement in higher frequency 0 Answers
Using a rotation in an if statement 0 Answers