Adding points for each cherry picked

In this section, we will edit the appropriate script to add five points for each cherry picked. Here are the steps:

  1. In the Project panel, select the Custom Scripts | CucumberManManager
  2. Edit the script
  3. Add the following class variable: public PointsManager _ptsManager;
  4. Add the following lines of code inside the nested if statement in the Update() method:
_ptsManager = GameObject.Find ("Score_Value").GetComponent<PointsManager> ();PointsManager.currentScore = PointsManager.currentScore + 5;  

The two lines of preceding code create a reference to the PointsManager script and, on the second line, increments the currentScore by 5.

The updated CucumberManManager script should be as follows:

 using System.

Get Getting Started with Unity 2018 - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.