Junior Programmer - Bonus Tools Tutorial, Example code not working

Hi, I’m following the bonus tutorials (PDF linked below) for the Prototype 2 project and I’m trying to get the animals to spawn left and right. I’ve written the code out as I’ve tried to understand it, but the two new methods do not seem to be working. Visual Studio is reporting that the two methods are unused members, however. They were typed as the example showed in the pdf document linked. What am I doing wrong here?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnManager : MonoBehaviour
{
    public GameObject[] animalPrefabs;
    private float spawnRangeX = 20;
    private float spawnPosZ = 20;
    private float startDelay = 2;
    private float spawnInterval = 1.5f;
    public float sideSpawnMinZ;
    public float sideSpawnMaxZ;
    public float sideSpawnX;


    // Start is called before the first frame update
    void Start()
    {
        InvokeRepeating("SpawnRandomAnimal", startDelay, spawnInterval);
    }

    // Update is called once per frame
    void Update()
    {

    }

    // Spawns animal at random location
    void SpawnRandomAnimal()
    {
        Vector3 spawnPos = new Vector3(Random.Range(-spawnRangeX, spawnRangeX), 0, spawnPosZ);
        int animalIndex = Random.Range(0, animalPrefabs.Length);
        Instantiate(animalPrefabs[animalIndex], spawnPos, animalPrefabs[animalIndex].transform.rotation);
    }

    void SpawnLeftAnimal()
    {
        int animalIndex = Random.Range(0, animalPrefabs.Length);
        Vector3 spawnPos = new Vector3(-sideSpawnX, 0, Random.Range(sideSpawnMinZ, sideSpawnMaxZ));
        Vector3 rotation = new Vector3(0, 90, 0);
        Instantiate(animalPrefabs[animalIndex], spawnPos, Quaternion.Euler(rotation));
    }

    void SpawnRightAnimal()
    {
        int animalIndex = Random.Range(0, animalPrefabs.Length);
        Vector3 spawnPos = new Vector3(sideSpawnX, 0, Random.Range(sideSpawnMinZ, sideSpawnMaxZ));
        Vector3 rotation = new Vector3(0, -90, 0);
        Instantiate(animalPrefabs[animalIndex], spawnPos, Quaternion.Euler(rotation));
    }


}

Thank you very much for anyone that can assist.

Not sure where you’re at in the PDF but the warning is correct: there are no hard references to any of the functions starting with Spawn

HOWEVER, there is a soft string reference in the InvokeRepeating to the SpawnRandomAnimal method so that one should be working.

Unfortunately these PDFs have had issues in the very-recent past (just a few days agi), with actual syntax errors (missing commas), so they’re unfortunately a bit on the unreliable side that way.

You might have better luck if you combine the above PDF approaches with this guy’s one-step-at-a-time approach:

Imphenzia: How Did I Learn To Make Games:

If you wanna see some more interesting spawning examples, check out my MakeGeo project:

MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo