Putting it together
So far, our hero can move to the left and right of the screen, but it is a little flat. As we have some animation in our spritesheet, let's put that into action.
As described earlier, in order to get the animation running, we will need the following prerequisites:
- An Animator component in our game object
- An Animator controller to manage our animation that is bound to the animator
- At least one animation clip to play in the controller
Setting up the animation controller
To get started, first we need to add the Animator component to the player's game object by navigating to Add Component | Miscellaneous | Animator in the Inspector pane. Leave all the other options alone for now.
Next, create a new animation Controller in Assets/Animation/Controllers
by navigating to Create | Animator Controller in the Project window (or by right-clicking on it while viewing the folder). Then, drag the new controller to the Controller property in the Animator component we just created...