Animating Damage on Sprites — Tracking Damage in Unity

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!

--

--

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
Jack Leavey

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!