Right now, our win condition works as expected, but the player still has control over the capsule and doesn't have a way of restarting the game once it's over. Unity provides a property in the Time class called timeScale, which when set to 0 freezes the game scene. However, to restart the game, we need access to a namespace called SceneManagement that isn't accessible from our classes by default.
A namespace collects and groups a set of classes under a specific name to organize large projects and avoid conflicts between scripts that may share the same names. A using directive needs to be added to a class to access a namespace's classes.Â
All C# scripts created from Unity come with three default using directives, shown in the following code snippet:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
These allow access to common namespaces, but Unity and C# offer plenty more that can be added with the using...