VFX — Adding player thrusters and visual player damage

Today we are going to add thrusters to our player ship as well as player damage visual effects.

Start by creating a thrusters game object based on the first frame of our thruster sprites.

Set the sorting layer to foreground on the Sprite Renderer and add the animation to the game object as well.

Set your thruster scale values as necessary to make it look right in the game and scene views.

Create a prefab for your thrusters and set it as a child game object parented to the Player game object.
Adjust position as necessary and save overrides.

Adding Player Damage VFX

Create the DamagedFire1 game object.

You don’t need to parent it yet, I’d suggest you don’t as it caused me positioning issues.

Add the necessary sprites to our animation and hit play to verify everything is looking good.

Now Duplicate DamagedFire1 and rename it to DamagedFire2.

You could simply turn the position.x value of it to negative for a symmetrical look, I chose to play w/ the positioning a bit.

This is what I ended up with, which was -1.24, -3.34, 0 on the Position.

Now, our game design here is that when our player loses a life, DamagedFire1 will appear.

When they lose a second player life, DamagedFire2 will appear.

Third life lost is game over.

So go ahead and disable these game objects in the hierarchy window.

We can go ahead and prefab each of them as well.

Create another script — DamagedFire

Since we want identical behavior for both DamagedFire1 and DamagedFire2 game objects, we create just the one script and assign it to both prefabs.

Not much we need to do here, just create a simple public ActivateDamage() method we can call from our LoseLife() method on our player script.

When called, this method simply sets the DamagedFireX game object to active thus showing it on screen.

If we ever implement a plus lives mechanism, such as a powerup, we would need to add another method here for deactivating these game objects.

On our player script, we add 2 serialized field game object variables.
One for each DamagedFireX game object.

And, once again, I’ve failed to null check these before taking a screenshot.

Drag assign our DamageFire1 and 2 game objects onto the Player script.

No, seriously. We’re done. Run it and see for yourself!

Next time we’ll look into Post Processing in Unity.




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

Recommended from Medium

Becoming a Great Developer

HowTo: Deploy Serverless Function on Google Cloud using Terraform

Let me help you organize your best Secret Santa ever

Duplicate navigation — the common issue happening in Facebook, LinkedIn and many apps… Solved by…

Install Davinci Resolve 16 on Arch (Sound issue fixed)

The Core Data Stack: Persistent Store Types

Adding Props for Cover in Unity 2021

Database Archival for MySQL Databases

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
GameDev Dustin

GameDev Dustin

More from Medium

Adding Occlusion Culling to our URP project

Creating a Homing Missile

The simplest way to create a First Person Shooter! (Part 3)

The Fourth Player Challenge: Problem Solving and Jumping