My 120-day journey to being a better Unity Developer — Day 17
Animating Sprites in Unity
Objective: Change the static image of the Power Up to use a more eye-catching animated version
Unity makes it so easy to create an animation, well a simple animation based on a sequence of images we provide.
Simply, select the set of images and drag the selection into the Hierarchy View. This will create a new game object or add an Animator component to an existing game object you dragged it to, an animation file that you will need to save, and an Animator.
Press Play and you will see an animated version of the Power Up.
OK, let's explain each of that new stuff.
It assigns animation to a GameObject in the scene. This component references the Animation Controller. When I saved the animation file, it created and saved the Animation Controller in the same location and named it GFX, the game object at the time that I dragged the set of images onto.
As the name implies, it controls the flow of animation clips. If you were to double-click on this GFX controller, you will be taken to the Animator Window. Here we see a diagram of the Entry point that flows to the PowerUpAnim that we created.
This is a very simple one, but you could have numerous animations that flow into each other. For example, a character animation that has an Idle that flows into a Walk then goes into a Run or Jump, etc. Here is an example:
Animation Clip is a simple “unit” piece of the motion. In our example, it is simply a flashing of colours. Back to the Animator window, if you double-click on the PowerUpAnim, we can see its properties.
In the Inspector you can see that the animation is looping and we see this when we play the game
We have only scraped the surface of the Unity Animation System but for now, we have a basic understanding that we can build from.
If you enjoyed reading this article give me a Clap, also if you would like to see more, “Follow” me, so you may be notified of future releases. You may also send me a message if you need any further help.