Day 27: Damage VFX using Animated Sprites in Unity

Objective: Show players that they are damaged.

Once you have the fire ball is smoke damage animation it’s time to add it to the player when they are damaged. We’ll do this by pulling in one of the sprites from the animation and make it a child of the player. Position the sprite where you would like. With it still selected, go to the animation window and create a Player_Damaged animation.

Once one side is done, duplicate it by using ctrl+D with the object select. Move the second on to the opposite side. Select both objects and disable them.

We we need to do is get a reference to both of the Engines. In the Player Script we will create two gameobject references, one for each side. We’ll serialize them so we can add the objects to the reference.

In Unity, pull the respective engine to the empty spot in the inspector.

Back in the script we need to enable them when the players health is low. In the Damage function we created earlier, after a life has been taken away we’ll want to check to see what is left. If it’s equal to a certain number one side will be enable and even less, the other side will get enabled as well.

And once lives is equal to zero we are destroyed. That’s all there is to make it look like the player is damaged.
Something we can do to make sure the objects aren’t enabled on game start is in the Start function set both to disabled state.

I am passonate on learning to program and use Unity to become a skillful Unity Developer