Trying to Invoke method: Spawner.SpawnObject couldn't be called.

I don’t have an error, it just says:

Trying to Invoke method: Spawner.SpawnObject couldn't be called.

This is the script:

#pragma strict

 // The object to be spawned
var SpawnObject : GameObject;

// in seconds
var SpawnStartDelay : float = 0;
var SpawnRate: float = 5.0;

function Start()
{
    InvokeRepeating("SpawnObject", SpawnStartDelay, SpawnRate);
}

// Spawn the SpawnObject
function Spawn()
{
    Instantiate(SpawnObject, transform.position, transform.rotation);
}

Thanks in advance! :slight_smile:

You want this:

InvokeRepeating("Spawn", SpawnStartDelay, SpawnRate);

SpawnObject is the name of a variable. Spawn is the name of the function you want to call, so that’s what you should pass to invoke.

Hi I have a similar problem whit my projekt.
The code looks like this

void Start()
{
    value = Random.range (1, 3);
    
    if (value == 1)
    {
        Invoke ("Heads", 3);
    }
    else
    if (Value == 2)
    {
        Invoke ("Tails", 3);
    }
}
void Heads()
{
    mainCamera.transform.position = new Vector3 (-17.5, 2, 0);
}

void Tails()
{
    mainCamera.transform.position = new Vector3 (17.5, 2, 0);
}

what am i doing wrong?