Day 9 of my Developer Journey: Stop spawning once the player dies
Now that we have a functioning spawning system, we need it to stop once the player dies. We will be using a more complicated of the GetComponent method.
Firstly, we will add a bool variable to our Spawn managers infinite loop.

Next we add a method that changes this variable.

Now we need to communicate with this code from the player’s code. First we add a variable for the method, so that we can globally interact with the method.

Next in the void start method we search for and assign this variable, while also setting up a null check.

Finally we communicate with the variable in the Damage method. Once it triggers, the value for our _stopSpawning variable to true, turning off the infinite loop.
