Adding Animation to the Fly

Similarly to our Slime, we’ll add a short animation that uses two sprites to give the illusion of movement, in this case, the flapping of wings:

1. Select the enemyFly GameObject.

2. Click the Add Component button and select Miscellaneous > Animator.

3. Navigate to the _animations folder in the Project window.

4. Right-click and select Create > Animator Controller.

5. Name the new controller “Fly” and open it.

6. Create an idle state.

7. With the enemySlime GameObject selected, open the Animation panel and create a new clip named “Fly_Move.”

8. Set the Sample value to 30 and add a curve for the Sprite Renderer’s “Sprite” property.

9. Assign the enemies_spritesheet_0 sprite to keyframes at 0:00 and 0:10.

10. Assign ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.