Using the Animator Controller to play sprite animations
In this recipe, we will create an Animator Controller to play 2D animations of a character. Unity's animation system is using the same principles for both 2D and 3D animation clips, which makes it quite intuitive to use.
Getting ready
First, you should have at least two sprite animations (or 2D sprite doll animations) ready. You can also go to the Chapter 03 2D and user interface animation\Recipe 04 Using the animator controller to play sprite animations
directory and open the Example.unity
scene. You will find an already animated Warrior
game object there. If you play the game, you can use the arrow keys (left and right) to move the character. It will play 2D animations accordingly.
How to do it...
To create an Animator Controller for 2D animation, follow these steps:
- Import your 2D sprite sheets to Unity the same way as in the Exporting a 2D sprite animation from a 3D package recipe.
- Drag and drop one of the child sprites (not sprite sheets...