- Home /
Flipping. (transform.Rotate VS transform.localScale)
Hey all, i seem to have stumbled upon a dilemma.
Ideally i want to be able to flip my sprite so that i wont need to use different walking animations.If i approach this by:
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
then as mentioned in many other threads this messes up the physics ( e.g onCollisionExit2D doesnt always work properly ).
However if the problem is approached by implemeting this
transform.Rotate(Vector3.up*180)
even though that should work, it wont if you ve checked the angle to be fixed. That means you have to uncheck the fixed angle option and manually set the z and x angle to be 0 in every update but i noticed that this is somewhat glitchy.
Any suggestions/ideas? How do you implement a Flip() function and keep the physics up and running? Thanks everyone for being awesome :)
Not sure if this is a glitch with 2D, but in 3D even with every angle fixed, using Rotate works, but normally I use Quartenion.Lerp() to smooth the rotations, ins$$anonymous$$d of using rotate.