2D Galaxy Shooter — Animated Damage and Thruster VFX on the Player
Today, I will go over how to add damage and thruster VFX to our player! This is our last visual addition before we go through post processing!
Adding the Thruster and Damage Sprites
- Find a good sprite for a thruster, add it to the game, then rename it Thruster.
- Position it to where it looks best on the player
- Make it a child of the Player so it travels with it.
- Add animations if you want.
- We are now done with the thruster!
- Find a good sprite of a fire with a smoke trail, add it to the game, then rename them Left or Right_Engine.
- Position them how you would like them on the Player.
- Make them a child of the Player.
- Turn their Transform off, making them invisible. This will allow us to turn them on later.
- I would suggest finding an animated sprite for these.
Adding the Damage Behavior
All we need to do here is add logic to the Damage() method saying that when we are damaged, turn on their Transform.
- Open the Player script.
- Add variables:
[SerializeField] private GameObject _rightEngine;
[SerializeField] private GameObject _leftEngine;
- Reference the two sprites in the Player’s script component.
- Head down to the Damage() method.
- Now below the “_lives -=1" line, enter these:
So, when lives = 2, start the right engine, and if 1, start the left engine. Pretty simple logic for crucial parts of the game!
Test it out and see how it goes!
That was how to add VFX elements to the Player! Next, I will go over how to apply Post-Processing and make this game up to AAA standards!
Thank you for your time!