Creating Enemy Explosions | Unity 2D
Jun 30, 2021
Objective: Play a sequence of explosion sprites when our enemy has been destroyed in the game.
First we need to create a new animation and add the explosion sprite sequence to our enemy prefab. If we look in the Animator window we can see that we have a new anim state for our enemy that is to be controlled by our explosion sequence.
We’re going to create a new parameter of type trigger called OnEnemyDeath. This will be the connection for our explosion sequence.
After creating a handle for our Animator:
Will be using the code below to talk to our trigger.
We now have a fully function explosion sequence!