Enemy Explosion VFX in Unity!

1. Creating Enemy Explosion Animation

  1. Select Enemy Prefab → go to Window → Animation → Animation
  2. When the Animation Window pops up, click ‘Create’ and ‘save’ it into the Unity folder.
  3. Click on the record button, then drag and drop in your series of Enemy explosion frames into the animation window.

2. Uncheck ‘Loop Time’ in Animation

3. Create a new state that will bridge between ‘Entry’ & ‘Enemy Explosion Animation’

  1. Select Enemy Prefab → Go to Animator Window.
  2. You will notice there are 3 text boxes included (Any State, Entry, and the animation that you created (In my case, it is ‘Enemy_Destroyed’))
  3. Currently, the Enemy explosion animation is being called out automatically. We need to create a new state (Empty/Null) that will run first, then runs Enemy Explosion.
  • Sequence: Entry → Empty → Enemy_Destroyed
  • This ‘Has Exit Time’ will cause a slight delay when the animation needs to be played. So, in order to play immediately, let’s uncheck this.

4. Parameters in Animator

  1. Go to Parameter window in Animator → Click on ‘+’ → select ‘Trigger’ → Rename it as ‘OnEnemyDeath’

5. In Enemy script

  • IMPORTANT: we need to wait few seconds before we destroy the Enemy in order to play the animation fully. We can add 3 seconds by writing Destroy(this.gameObject, 3f);
  1. The enemy’s speed would reduce down when explodes.
  2. The enemy can no longer collide with the player when explodes.
  1. Create a bool variable _isEnemyDying which will be false at start.
  2. Add if statement if (_isEnemyDying == false) so that OnTriggerEnter2D() will run only when it is false.
  3. We will turn _isEnemyDying = true when the enemy collides with either the laser or the player.
  4. We will also write _enemySpeed = 2f; to reduce the enemy’s speed.




XR Unity Developer / Designer / Architect

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to get the best Hash

The Attraction of Learning (A Students Experience)

AWS Lambda and Symfony

Ruby Web Scraping Using Nokogiri

Destruction — Layer 4 Main Features

Current one with for.

Language-Integrated Queries: LINQ

Adding Cinemachine to the Project

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Du Young Yoon

Du Young Yoon

XR Unity Developer / Designer / Architect

More from Medium

My journey becoming a Unity game developer: 2.5D Infinite Runner-URP and Player’s 3D model added

In just 4 steps, Make a modular moving platform in Unity

Indy Pro ’22: Talent Training

Lights and Fog and in Unity’s HDRP