Creating Enemy Explosions

<p>Good shooting games have explosions. So let&rsquo;s implement some into my Space Shooter.</p> <h2>Create the Animation in Unity Editor</h2> <p>I created the animation in the same fashion that I have&nbsp;<a href="https://medium.com/@shane.makanuilopes/animating-my-sprites-in-unity-870619908e1e" rel="noopener">before with my power ups</a>&nbsp;using the assets from&nbsp;<a href="http://gamedevhq.com/" rel="noopener ugc nofollow" target="_blank">GameDevHQ</a>. In this case, I implemented an explosion sequence on my Enemy prefab. The intial set up then looked like this:</p> <p><img alt="" src="https://miro.medium.com/v2/resize:fit:770/1*LRVqtb1D5WEKMit2RxqB8w.png" style="height:484px; width:700px" /></p> <p>Initial Enemy explosion set up in Unity</p> <blockquote> <p>Note: Each enemy has a unique animation controller when it&rsquo;s spawned, so it&rsquo;ll act independently per Enemy instance.</p> </blockquote> <p>Now with this set up, it made the animation run nicely. But it ran as soon as the Enemy spawned, as you can see by the Animator layers. Upon entry, the animator runs right to my new&nbsp;<strong>Enemy_Destroyed_anim</strong>. So next step was to add a transition in the Unity Editor to make the animation conditional.</p> <p>First I created and Empty object as a non-animation to occur upon entry. Then I implemented a transition from the Entry to the Empty object, then from the Empty object to the explosion animation. I named the trigger&nbsp;<strong>OnEnemyDeath</strong>.</p> <p><a href="https://medium.com/@shane.makanuilopes/creating-enemy-explosions-f0c9fc598eb8"><strong>Read More</strong></a></p>