Now that we have a functioning animator controller, it’s time to accept player input so that we can actually pause the game and bring up the menu.

To do this, create a new C# script called PauseController. This will be a very simple script; it's 20 lines including whitespace, because all it needs to do is update the isPaused parameter of our animator controller. Here it is, in all its glory:

using UnityEngine;public class PauseController : MonoBehaviour
public Animator canvasAnimator;
int isPausedHash;
void OnEnable ()
isPausedHash = Animator.StringToHash ("isPaused");
void Update ()
if (Input.GetButtonDown ("Cancel")) {
canvasAnimator.SetBool (isPausedHash, !canvasAnimator.GetBool …

Derek Stobbe

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store