I need to set an animation of flipping in a 2D game on Unity. How is the best way to do this?
I’m trying something like this pseudo code:
void FixedUpdate(){
if(lastSide!=currentSide)
flip();
}
void flip() {
if(lastSide == 1) // if is facing right
animator.SetTrigger(“flipToLeft”);
else if(lastSide == -1) //if is facing left
animator.SetTrigger(“flipToRight”);
this.player.transform.localScale = new Vector3(lastSide*-1,1f,1f);
}