In this section, we will fully implement our player's health. We will start the Cucumber Man with three lives, each with a full health value of 100. We will update our scripts so that the Cucumber Man loses health when a cucumber beetle attacks him. Our approach will be to deduct one point from the Cucumber Man's health for every second that it is colliding with a Cucumber Beetle. We will also script the HUD's health bar and start with that task in the next section.
Before we get started, you should open your Unity game project. Alternatively, you can download the Starting-Chapter-11 Unity project available from the publisher's companion site.