The role of the game controller is to keep score and other game-wide features. For now, we'll just keep score. Let's add that as follows:
- In the root of the Hierarchy, create an empty game object, name it GameController.
- And reset its Transform.
- In the Project Assetts/ARPlayBall/Scripts/ folder create a new C# script named GameController and drag it onto GameController as a component.
Open the GameController script for editing as follows:
File: GameController.csusing UnityEngine; using UnityEngine.UI; public class GameController : MonoBehaviour { public int hitPoints = 10; public int missPoints = -2; public BallGame ballGame; public Text scoreDisplay; private int playerScore; void Start() { ballGame.OnGoalWon.AddListener(WonGoal); ...