Animations are the essence of life in your games; they can make your games feel and look alive.
In order to breathe life into your games, you will need a list or a sequence of sprites that you wish to animate. Next, you need to open your ‘Animation’ window. I like to place the ‘Animation’ right where I have my ‘Game’ window. This allows me to work on my animations and view them simultaneously in my ‘Scene.’
When you have an ‘Animation’ window opened, proceed with the selection of the GameObject that you wish to animate - for this demonstration, I will be animating the Triple-Shot Power-up created in the last article. You can then click on the ‘Create’ button and create an animation file in your project repository. I have created an ‘Animations’ folder beforehand since I would like to keep my ‘Project’ explorer as clean as possible.
We can then see two new files created for us in the ‘Project’ explorer as well as a new ‘Animator’ component that has been automatically added to our GameObject.
Let’s see the overview of the ‘Animation’ window.
- 1.) This is a dropdown menu, which shows the list of all animation clips attached to the selected GameObject. You can cycle through them or create a new one.
- 2.) The Timeline is where you will add keyframes to your animations. The timeline is shown in seconds by default but can also be shown in frames.
- 3.) The ‘Add Property’ button allows you to add parameters to your GameObjects components, which then can be animated.
- 4.) To control the playback of the Animation Clip, use the Playback Controls.
- 5.) This is the ‘Sample’ rate, which shows the frames per second at which the animation clip will be played.
- 5a.) This is an options window, where you can switch between the Seconds/Frames on the Timeline or where you can show the Sample rate and also set the Sample rate to specific predefined values.
Creating the animation:
Now that we are familiar with the ‘Animation’ window, we can start animating the power-up. The first thing we have to do is to simply take our sprite sequence and drag-n-drop it into the ‘Timeline.’
Now our animation is pretty much set; let’s try it out!
Looking quite good, but to me, the text is blicking a bit too fast, so I will be adjusting the ‘Sample rate’ down a bit.
We can also take a look at the ‘Animation Clip’ - and here, we can see that every animation will be looping by default. But that is what we want in this case, but it is something to keep in mind.
When you try opening the other animation file that was created - the ‘Animator Controller,’ the ‘Animator’ window will open.
In this window, we can create and control different states that our GameObject can be in and set the behavior that should be happening in each state. That is a topic that I will be covering in the upcoming articles, so stay tuned!
But that is it for now, thank you for reading and feel free to follow me for more articles - and as always, good luck and see you next time!