In this section, we will edit the appropriate scripts so that the Cucumber Man can earn points, related to cherries, based on the following criteria:
In-game event | Points |
Cucumber Man picks cherry | + 5 |
Cucumber Man hits beetle with cherry | + 10 |
In this section, we will create and edit a script to manage our points and to display them on our game's HUD. Here are the steps:
- In the
Hierarchy
panel, select theHUD_Canvas
|Score_Value
- In the
Inspector
panel, click theAdd Component
button - Select
New Script
and name the scriptPointsManager
- In the
Project
panel, clickFavorites
|All Scripts
- Drag the
PointsManager
script to theAssets
|Custom Scripts
folder - Double-click the
PointsManager
script to open it in an editor - Edit the script so that it matches the following code
The first section of the code contains the namespace import statements and the PointsManager
class declaration:
using System.Collections; using System.Collections...