Damage VFX using Animated Sprites in Unity!

addam davis
3 min readMay 27, 2021

--

Objective: Adding visual effects to your player to show damage

To begin, take the first sprite from your damage animation and drag and drop it into the play, or ‘child’ the sprite to the player. This will attach the sprite to move with the player.

Scale the sprite to be appropriate in size in relation to the player. With the sprite being parented to the player you can drag the sprite to the perfect position.

Once you have it in position rename the sprite to Right_Engine.

duplicate and rename this to the Left_Engine and place this duplicate to the next area of the player. Depending on the player you can sometimes make the X axis the opposite of the right engine. Now deactivate both engines.

Open the player script and we need to add variables for the Engines.

Serialize both the engines and add them to their references.

We need to add logic for when we need these to become active/visible. Inside the method that monitors the player’s lives. We need to use an if statement.

With the function written and working we can now add our animations. Select one of the engines and open the animator. Create new and label it, Engine_Failure_anim. Select all your sprites for this animation and drop them into the animator.

The engine you didn’t use you need to add the Animator component. Now place the animation controller into the empty animation controller slot.

Now your sprites are fully animated and your player show damage after being hit.

You now know how to add/activate animation to your player and other objects in your game. Remember to experiment with your code and I’ll see you in the next tutorial.

--

--