Hi all! I’m new to unity, and and amateur c# user. I have a submarine sprite that I would like to flip by the y axis when rotated more than 90 degress, and less than -90 degrees so that it won’t be upside down. It’s rotated by mouse movement, which I’ll give the code if necessary. I’m not sure why but this doesn’t seem to work. Any help would be appreciated!
Code:(rot90 is a bool)
if (transform.rotation.z > 90 & transform.rotation.z >-90)
{
rot90 = false;
}
if (transform.rotation.z < 90 & transform.rotation.z < -90)
{
rot90 = true;
}
if (rot90 == true)
{
Vector3 scale = transform.localScale;
scale.y = -22;
transform.localScale = scale;
}
if (rot90 == false)
{
Vector3 scale = transform.localScale;
scale.y = 22;
transform.localScale = scale;
}