How to communicate between scripts

Objective: Use the GameObject.Find method.

Let’s connect two scripts together. We will reach out to another function in another script that will then turn off the spawn after the player dies.

We begin by setting in our player the ability to connect to the spawn manager to get the spawn manager component.

We then want to do a check where if the player dies, we want to do a OnPlayerDeath() function. When we run this function, we want to use our handle to the spawn manager and run a new function in the spawn manager called StopSpawning().

Our new function simply turns off the spawn capabilities. This shuts off all future spawn potential.