Book Image

Mastering Unity 5.x

By : Alan Thorn
Book Image

Mastering Unity 5.x

By: Alan Thorn

Overview of this book

Mastering Unity 5.x is for developers wishing to optimize the features of Unity 5.x. With an in-depth focus on a practical project, learn all about Unity architecture and impressive animation techniques. With this book, produce fun games with confidence.
Table of Contents (16 chapters)
Mastering Unity 5.x
Credits
About the Author
Acknowledgment
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

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 custom texture.

Creating a red, damage UI object

Use the Rect Transform tool (T), as shown in the following screenshot, to resize the image plane to fill the canvas, and thereby the screen. Then use anchoring to attach each corner anchor to the respective...