Jackson's Documentation - kreetin7/SuperHotClone2018 GitHub Wiki

How the game resets on winning or death

In order to create a working restartable scene you first need to create an empty object inside your scene. I named it "GameManager". Create a new script (GameManagerScript.cs) and attach it to this empty object. This object is meant just to be in the scene to hold the script. In the script first add using Unity.SceneManagement to the top. I use two main bools, isAlive and npcisAlive. Both are checks to see whether or not the npc or player has been hit. isAlive is set to false when the players collider collides with another collider tagged as "npcbullet". This can be found in cubemiove.cs. The npcisAlive is set to false if both npccheck1 and npccheck2 don't exist in the scene anymore (i.e. they are shot and destroyed). npccheck1 and npccheck2 are public game objects assigned to either enemy object in the inspector. When both npcchecks are set null, npcisAlive is set to false which then sets off an if statement starting the SuperHotText coroutine. There are if and else statements to end the coroutines after both bools are set back at the end of the coroutine. Both SuperHotText coroutine and GameOverText use the Unity.UI text object which is assigned in the inspector. There are two empty text objects set in the inspector in the canvas. The coroutines set these texts to say "SUPER" "HOT" on winning and "Press R to restart" on death. There is an if statement for if you press R it restarts the scene.