So, I have a weapon that rotates towards my mouse position but the issue is if I put my mouse on the left side the weapon is upside down. So I’ve tried flipping it on the y axis according to its rotation but it constantly switches between both states (As in the y scale goes from - to + instead of sticking to one according to my mouse position.) Im not sure how to fix this. Any tips?
//Update Looking Direction
var rotationVector = transform.rotation.eulerAngles;
if (rotationVector.z < 90 && rotationVector.z > -90)
{
lookingLeft = false;
}
else if (rotationVector.z > 90 || rotationVector.z < -90)
{
lookingLeft = true;
}
if (lookingLeft == true)
{
transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y * -1, transform.localScale.z);
}
if (lookingLeft == false)
{
transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y * -1, transform.localScale.z);
}