O'Reilly logo

Mastering Unity 5.x by Alan Thorn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Damage and feedback

The Health component allows objects to have health and therefore to take damage during attacks; but, we also want more UI feedback for the player during a battle. Specifically, when the player is attacked and hit by a zombie, the screen should throb or flash red, indicating that damage has been sustained. We can achieve this by using a colored sprite overlay whose opacity is animated from transparent to visible and then back again. To achieve this, create the colored overlay by choosing GameObject | UI | Image to create a new image object. Name this Panel_Damage_Throbber. Add this as a child object of the Health UI Canvas created previously. Select red for the Color field to express danger, damage and pain, or you can use a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required