How it works...
The Capsule-spawnPoint objects represent candidate locations, where we might wish to create an instance of our ball Prefab. When our SpawnPointManager object, inside the Cube-player GameObject, receives the Start() message, the respawned GameObject array is set to the array, which is returned from the call to FindGameObjectsWithTag("Respawn"). This creates an array of all the objects in the scene with the Respawn tag—that is, all our Capsule-spawnPoint objects.
When our SpawnBall object GameObject Cube-player receives the Start() message, it sets the spawnPointManager variable to be a reference to its sibling SpawnPointManager script component. Next, we use the InvokeRepeating(...) method to schedule the CreateSphere() method ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access