im trying to make this sprite face in the direction that it last faced after using the joystick:
if (Mathf.Abs(angle) > 90)
{
facingRight = false;
Vector3 scale = transform.localScale;
scale.x = Mathf.Abs(scale.x);
transform.localScale = scale;
}
else if (Mathf.Abs(angle) < 90)
{
facingRight = true;
Vector3 scale = transform.localScale;
scale.x = -1;
transform.localScale = scale;
}
if (facingRight)
{
Vector3 scale = transform.localScale;
scale.x = -1;
transform.localScale = scale;
}
else if (!facingRight)
{
Vector3 scale = transform.localScale;
scale.x = Mathf.Abs(scale.x);
transform.localScale = scale;
}
All it does is snap back to facing the default direction when I stop using the joystick.
variable angle doesnt print any value when joystick isn’t being used (doesnt say angle is 0, possible it’s null)