Damage VFX Using Animated Sprites in Unity

The next step in setting up visuals in my 2D Space Shooter is adding damage effects to the player when getting hit.

  • I first added my damage sprite to the scene and positioned it at my preferred location. I duplicated this sprite and did the same. Then I set them as inactive in the Inspector.
Adding & Positioning Damage Sprites

I wanted one of them to be activated on the first hit, and the second one activated on the second hit.

  • Inside the “Player” script, I added the following code.
[SerializeField]
private GameObject _leftEngine;
[SerializeField]
private GameObject _rightEngine;
  • Back in Unity, I dragged the left and right engine sprites into their respective slots in the Inspector.
Assiging Objects
  • Back inside the “Player” script I added the following code in the Damage() method.

I have animations to add to the damage sprites, so that’s what I did next.

  • I selected the “Right_Engine” object and created a new animation called “Engine_Failure_anim”.
  • I dragged the animation files into the Animation panel.
  • In the Projects panel, I changed the name of the Right_Engine controller to “Engine_Failure”.
  • With the “Right_Engine” object selected in the Hierarchy panel, I dragged the “Engine_Failure” controller to its respective slot in the Inspector panel.
  • I then added an Animator component to the “Left_Engine” object.
  • With the “Left_Engine” object selected in the Hierarchy panel, I dragged the “Engine_Failure” controller to its respective slot in the Inspector panel.
Dragging Controllers to Respective Slots

Testing the Player Damage VFX

Time to see how it looks. Fingers crossed.

Looks fabulous!

Thank you for reading my article. Please follow me if you would like to continue to see my 2D Space Shooter game progress.

--

--

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