In the previous section, we modified the CucumberManManager script to track how many lives remain and to destroy the UI image elements as appropriate. In this section, we will modify that script to accomplish the following when a life is lost:
- Play the die animation
- Respawn the player on a respawn pad
Let's start by modifying the CucumberManManager script:
- Add the following class variables:
public Transform SpawnPad1;
public Transform SpawnPad2;
public Transform SpawnPad3;
- In the Hierarchy panel, select the CucumberMan GameObject and, in the Inspector panel, scroll until you locate the Cucumber Man Manager (Script) component.
- Drag SpawnPad1, SpawnPad2, and SpawnPad3 from the Hierarchy view to the designated spots in the Inspector panel. See the following for details:
- Modify the bottom section...