Beaten, Battered, Bruised: Adding Damage VFX To Your Game
You’re in the zone blasting enemies and sudden your character just falls over and dies! What a killjoy, today we’ll talk about visualizing damage to help give your players visual cues on on when they’ve take damage or are very close to death. The best way to show this is through particle systems (or animated sprites if you’re working in a 2D game) changing the pose/animation of your player’s character to limp/stagger to show they’re low on health.
This article will use a very basic particle system to represent the damage. There are much better articles and resources on Unity’s Particle System but essentially (here and here) when the player is about to die they’re going to be covered in a thick jet of flames. I’ll be using Atomic Shooter to demonstrate as an example but this should be applicable to any sort of game.
Alternatively you can also use an animated sprite (like I cover here) to help signify when the player is ready to kick the bucket. Use whatever fits your situation best.
Start by opening an existing project or starting a new project. If you have an existing character that’s great but for our example we’ll use a cube to represent the player.
Next let’s create a particle system by right clicking on the Hierarchy Effects > Particle System this will create a really basic looking particle system but it’ll work fine for purposes. Make sure to center it on the cube and have it point up like it’s shooting out of the cube make sure the particle system is looping.
Next we’ll prefab the particle system you can name Flames if you’re following along and then we’ll go ahead and delete it from the Hierarchy. It will come back later when we call it from the Player script that we’ll attach to the cube you can see it below. This script attaches to the player.
With the script attached to the player set the player health as desired and be sure to attach the Flames prefab VFX to the appropriate slot.
Now let’s see it in action.
Cycling down in health we finally hit “critical” mode where the player’s heavy damage VFX triggers.
There you have it, a very rudimentary but very effective damage VFX system. This helps provide feedback to the player when they’re on their last legs, when they get hit with a fire or poison attack, or to signify something positive like healing or a buff. Hopefully this gives you the tools to let your imagination run wild. Until next time, happy coding.