We will use the CucumberManManager script to keep track of the number of lives the Cucumber Man has remaining. Edit that script and make the following changes:
- Add the public static int livesRemaining; class variable. We will use this variable to track the number of remaining lives.
- Add the public Animator anim; class variable. We will use this to play the Cucumber Man's death animation.
- Add the livesRemaining = 3; statement to the bottom of the Awake() method.
- Add the following if statement block to the bottom of the Update() method:
if (livesRemaining == 0) { anim = GetComponent<Animator> (); anim.Play ("CM_Die"); }
As you can see in the changes to our Update() method, we are simply checking ...