Rotation on the negative X axis will not be checked..

Updated 7 days ago in General
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on January 13, 2018

Hello Devs! I have problem with checking if my negative x rotation is less than -25f..I want to stop rotation at -25f if the rotation is less than -25f, but this if statement dont even print something in the console if rotation is less than -25f.. This is my code, and i have the exactly same code right below, except values is positive and that code work perfect, but this code with just negative values dont work, i really dont know why?

if (Input.GetKey(KeyCode.DownArrow))
myBody.velocity = new Vector3(0f, 0f, -smoothForceZ);
transform.Rotate(new Vector3(-100f * (Time.deltaTime * rotationSpeed), 0f, 0f));

float rotationNX = transform.eulerAngles.x;

if (rotationNX < -25f)
transform.rotation = Quaternion.Euler(new Vector3(-25f, 0f, 0f));


  • Liked by
1 on January 13, 2018

Rotations float values are always between 0 and 359.99999

if(rotationNX < 0f) rotationNX += 360f;
if(rotationNX >= 360f) rotationNX -= 360f;
7 days ago

Yea, but how can i stop rotation on -25f when the gameobject reaches that value on the X axis?

Show more replies
  • Liked by