Question by
unity_W7Ha2sTtt9rreg · May 04, 2021 at 08:08 AM ·
rotationangleif-statements
IF statment / scale flip isn't working,If statement not working
Hello, my sprite is rotating in the angle to my mouse and I want it to flip his Y Scale if the angle is higher than 90 and lower than -90. But when the Z angle is 0 the sprite flip his Y Scale for no reason. please help
if (transform.localRotation.eulerAngles.z >= -90 && transform.localRotation.eulerAngles.z <= 90)
{
if (transform.localScale.y < 0)
{
characterScale.y = characterScale.y * -1;
}
}
else
{
if (transform.localScale.y > 0)
{
characterScale.y = characterScale.y * -1;
}
}
transform.localScale = characterScale;
,Hello, I want the sprite in my game rotate in the angle of my mouse and flip the x scale if the angle is higher than -90 and lower than 90. But when it is under 0, it flips for no reason. Pls help guys
if (transform.localRotation.eulerAngles.z >= -90 && transform.localRotation.eulerAngles.z <= 90)
{
if (transform.localScale.y < 0)
{
characterScale.y = characterScale.y * -1;
}
}
else
{
if (transform.localScale.y > 0)
{
characterScale.y = characterScale.y * -1;
}
}
transform.localScale = characterScale;
Comment
So, basically, what stops you from adding X axis inversio as well? Keep in $$anonymous$$d that angle values may go further -90 and 90, they don't clamp by 180 or 360. Also, I'd suggest using SpriteRenderer.flipX value (just set it to 'true' or 'false' to flip or unflip).