Damage VFX using Animated Sprites in Unity

Houston, we have a problem.

Tristan Mendiola
3 min readJul 1, 2022

OBJECTIVE: Represent Player Damage via a visualization of damaged thrusters.

In previous articles, I created a visual representation of Player Damage with the UI. It represented the amount of lives we had left. I’m going to take it to the next step now by making Damage VFX.

Visual Effects, or VFX, are employed to represent phenomena in a tangible way. In this instance, if our spaceship gets hit by something, it would make sense for it to begin to smoke or for the engines to burn.

To start things off, add in the Sprite that will represent your Player Damage. Drag and drop it into the Player Game Object to make it a Child of that object. This way, when the Player character moves, the Child Object will move with it.

Animate the Thruster utilizing methods established before.

VFX Coding

Establish the variables for our engines. We’re creating 2 separate variables for our left and right engines. Since they are heavily related, you can use the same line of private GameObject to create them. It’s typically best to not do this, but it’s okay in this instance.

Define the Prefabs in Unity.

In the Start() method, I’m going to set both engines as false.

We want to create the method in our Player Script’s Damage() method. I’m going to establish it that if we reach 2 lives, our right engine is going to be active. If we reach 1 lives, our left engine is going to be active as well. We don’t need to establish code for 0 lives because then our Player will be destroyed.

Now, when we take damage, the engines will show the animation that we set.

Ouch!

--

--

Tristan Mendiola

A passionate and driven C# and Unity developer experienced in making 2D and 2.5D titles. Deeply invested in blending the culture of people with technology.