# if rotation < -45 && > -140 issue

I have a problem with this if statement.

If the rotation is < -45. And > -140

Then this statement would be true when the rotation is = -90?

And it would be false if the rotation is = -170?

I'm using the negative values because unity rotation goes from -180 to +180.

I tried using a full 360 scale, that also didnt work. that Statement looked like:

if the rotation is > 245 & < 325

Then do stuff

If you can change where the 0 value of the rotation is from the West point to a different one would also be a useful option

Thanks for any help

Code that is being executed:

        if (transform.rotation.z > -140 && transform.rotation.z < -45)
{
if(rotationSpeed < 150f)
{
rotationSpeed += 150f * Time.deltaTime;
} else
{
rotationSpeed = 150f;
}
print("135");

} else
{
if(rotationSpeed > 70f)
{
rotationSpeed -= 150f * Time.deltaTime;
} else
{
rotationSpeed = 70f;
}
print("246");
}


It turns out that Transform.rotation is a Quaternion. This is why I can't use the z value from it.

The Transform.localEulerAngles does use 0 to 360, so changing the parameters of the if statement will solve any issues:

if (transform.localEulerAngles.z > 250 && transform.localEulerAngles.z < 325)
{
if(rotationSpeed < 150f)
{
rotationSpeed += 150f * Time.deltaTime;
} else
{
rotationSpeed = 150f;
}
print("135");

} else
{
if(rotationSpeed > 70f)
{
rotationSpeed -= 150f * Time.deltaTime;
} else
{
rotationSpeed = 70f;
}
print("246");
}