GameDev : VFX Effects (Part I)!

Matteo Lo Piccolo
3 min readJun 25, 2021

--

Today we make a little change in our Game with VFX effects!
Small changes, but they improve our Game a lot.

In my project I have these effects : Thruster for Player, Asteroid, Enemy explosion, etc.

How can we use these in Game?
First of all, every VFX effect has own animation, and its works like other animation we have.
Then, we simply think : when this animation comes to play?
For example, Enemy explosion VFX.

We play, hit the Enemy with Laser, so when Laser hit it, we Destroy() it.
But BEFORE, we need ti instantiate the Enemy Explosion animation.

And because we have to Instantiate it, we have to make it a prefab, and position it at the position of Enemy when it dies.

Let’s try to set up.
Open the Game Scene, and after open teh Enemy prefab

Now, as we learned through these articles, we create the animation for explosion

Highlight Enemy, go to Windows, Animation, Animation to open the Animation window

Click on Create, go in Animation folder, and name the animation (I call it Enemy.Destroyed.anim)

Press Record, take all the animations you have and drag them into animation window, then click Record again to Stop

Now we have Enemy Destroyed Animation set up.

Let’s try to Play and see

The animation works “perfectly”, the problem is WHEN it occurs.
This because in the Animator, the animation is probably set to start when the object is in Game, so every time Enemy is Instantiate, the animation starts.
Is perfectly fine, we simple have to modify the moment when this happen.

Other than that, Unity sets the default animation to “LOOP”, and we need to make the explosion happen only once.

First, stop the animation to loop

Now, enter into Animator

If we look the Animator window

Enemy_Destroyed_anim is ORANGE, and this means this is the default animation of Enemy.
To change that, we have to create another “state” to set the default animation to Empty (or Idle), and “set as Layer Default State”

Now form IDLE, we create transition to Enemy_Destroyed

If we click now on the little arrow in the transition, we can decide :
“At what moment do we have to switch from Idle to Destroyed? And what kind of parameter do we need to tell the animation to start?”

In this window, click the arrow, then in top left corner go to Parameter, and click + button.

As we see, we now need to pass a type of parameter to set up the animation.

In the next article, let’s see how to do it!

--

--

Matteo Lo Piccolo
Matteo Lo Piccolo

Written by Matteo Lo Piccolo

Always in love with programming, even if late (I'm already 39 years old) I decided to follow my dream! We will see how far my passion will take me!

No responses yet