- Home /
Cannot flip sprite when Z rotation >= 90 & <= -90
Basically I want a weapon's sprite to flip when the Z rotation is greater than 90 and less than -90. I've written this but it just refuses to work along with multiple different attempts using different angles and stuff, but I just cant figure it out.
void Update () {
if (transform.rotation.eulerAngles.z >= 90 && <= -90) {
sprite.flipY = true;
} else
sprite.flipY = false;
}
}
Answer by Rocketman_Dan · Oct 09, 2017 at 05:35 AM
That's not how if statements work. what you need is
if(transform.rotation.eulerAngles.z >= 90 || transform.rotation.eulerAngles.z <= 90){
}
You needed an or operator, not and. And you also needed a left operand for the "<= 90 " comparison.
Your answer
Follow this Question
Related Questions
Help with rotating a sprite with mouse. 2 Answers
Get a single number for rotation (2d game) when using Quaternion.FromToRotation 1 Answer
Arm Rotation toward Cursor Script Help 1 Answer
How to Rotate 2D Object Without Changing Axis Orientation? 1 Answer
Move a 2D "Chains" end-effector to a certain point via physics. 0 Answers