Animating Sprites in Unity
Objective: Animate the powerup sprite.
Unity has a built-in animation system which makes sprite animations easy to implement. Pull the triple shot powerup prefab into the hierarchy and while selected, go to Window, Animation, then Animation and dock the window that pops up next to the game window. Click create and for best practice, create a folder called Animations. Go into the folder and save the animation as Triple_Shot_Powerup_anim.
Here we can create key frame animations. Since we have out animation frames ready in a folder, press the record button, make sure the triple shot powerup is selected in the hierarchy and select all the sprite frames in the folder and drag them into the animation window. You can play the animation and view it in the scene view above. If you’re happy with it turn off the recording. When you turn off the recording it create the animation and animation controller. The controller as in the name, controls the animations.
Double-click the controller to see the animator. Unity sets animations to loop by default.
Now that we have an animating powerup, in the next post, we will create the logic for how long the power up will last when collected.