I opened the Enemy prefab and created a new animation called Enemy Explode.
On the First Frame of the Animation I also Selected to turn of the Box Collider 2D. This will stop collision from happening to dead enemies.
Now this Animation plays a little slow so I changed the Samples from 12 to 60.
I only want the animation to play once so I changed the Loop Time to False.
I then added an Empty State to the Enemy Animator and Changed it to Be the Layer Default State. I also added a transition from the Empty State to the Enemy Explode State and back.
I added a
bool parameter called Is Dead and set the transitions to use the new parameter. I also turned of the Has Exit Time and Fixed Duration. I find that when doing sprite animations I get a smoother transition by changing these settings.
I then modified the Damageable Behavior since this is where I am Destroying the Game Object. I added a death time this is so the animation has time to play before the Game Object is Destroyed. I also added an Animator and an int Is Dead for the animator parameter. I set the Animator and the Animator parameter in the Awake method. In the Damage Method I change the Destroy to play the animation if there is an animator and then I Destroy the Game Object with the death time.