Animating Damage on Sprites — Tracking Damage in Unity

Jack Leavey
Jun 5, 2022

Currently in my 2D example game, the player has a lives tracker, but we can expand upon the system by adding visual feedback to the player’s model when they are “damaged”.

A damaged spot on the player.

I added two new children to the player object, one on each wing with this visual. They are disabled by default.

In order to add them as we take damage, we need to add both of these gameobjects as variables.

Inside of the PlayerController C# script.

And finally, we need to check the damage state whenever the player takes damage, and enable the correct objects!

These two “if” statements will turn the damaged visuals on as we lose health.

Let’s see it in action!

Some nice extra visual feedback!

--

--

Jack Leavey

I am a software engineer with years of experience branching into game development, specifically in Unity. Follow along for guides on creating game mechanics!