I want to animate a card flipping from its front face to its back face. Both card faces have different sprites as their background.
I have an Animator
component attached to my card. The animator rotates the card 180 degrees around the z-axis, and changes the background sprite when it has rotated 90 degrees. That all works correctly.
The problem is that the sprite changes back to the original sprite once the animation clip is complete. I tried adding an animation event to the end of the animation clip event's function and having the animation clip do GetComponent<SpriteRenderer>().sprite = ...
, but that doesn't work either. Even if I change the card's sprite in the Unity Inspector, that doesn't work (the sprite doesn't actually change).
Here's what my animator looks like (the Idle
animation has no clip attached to it):
Here's what one of the animations looks like:
Is there a way that I can have my animator change my game object's sprite, and then have the game object maintain the new sprite until it is changed again? I know I can do it programmatically through a coroutine, but I don't want to do a workaround if it's not necessary.