O'Reilly logo

Virtual Reality Blueprints by John Williamson, Charles Palmer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scripting the mole game controller

Now we will focus on building a controller script for the mole game. This script will manage the Score Board text elements and the starting times for the moles:

  1. Begin the process by creating a new script on the MoleGame GameObject. Name the script MoleGameController.
  2. Double-click the new script to open it in your editor.
  1. Modify the script to match the following functions and methods:
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class MoleGameController : MonoBehaviour {     [SerializeField] Text timerUI, scoreUI;     [SerializeField] float startingTimeInSeconds = 30f;     List<MoleController> moles;     int score = 0;     float timer = 0f;     bool isTiming; void Start() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required