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 asset

The next phase of this project is to construct the controller script for the mole. We will tackle the script in chunks, with descriptions to provide more information on the purpose of each method and function:

  1. Double-click the MoleController script.
  2. Modify the script to add the necessary variables:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class MoleController : MonoBehaviour {     [SerializeField] float popupSpeed;     [SerializeField] float distanceToRaise;     float maxMoleTime = 4f;     Animator animator;     AudioSource audioSource;     bool canActivate = true;     bool isActivated = false;     bool wasActivated = false;     IEnumerator runningCoroutine;     int timesHasBeenWhacked = 0;
  1. The Start() function ...

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