Objective: Create some nice 2D VFX explosions with the Animator in Unity.
Requisites: A secuence of static sprites imported in your Unity project.
If you don’t have the Animation tab opened go to Window - Animation - Animation or press Ctrl + 6. Move to an appropiate location and let’s get into it.
Drag your first frame of the sprite secuence to the hierarchy, with the Gameobject selected, in the Animation tab press Create. Make a folder called Animations and give your new animation a name, in our case Explosion_anim is fine.
Now let’s drag all the sprite secuence into the Animation timeline, if you press play to test your game, the animation will be looping forever.
Easy fix: Select your own animation, Explosion_anim in our case and deselect Loop Time.
In test mode, the moment you activate the Gameobject in your hierarchy, the animation will play once and everything will be looking nice. And that would be it for this sprites animation tutorial.
Tip: Some situations this animation would work would be where an enemy, an object or our player gets destroyed and after dying, an empty gameobject with the explosions animation attached spawns and also gets destroyed or deactivated after 2–3 seconds.