Weird script behaviour

Hi,

I’ve encountered the following problem as I was following a Brackeys tutorial on youtube.

I made a new script as usual and copy/pasted what I was instructed to do and somehow the script didn’t load at all. I have to mention that I got an error that the namespace wasn’t right or something. But that was fixed by deleting the whole script and making a new one from scratch. That didn’t gave any errors, but it didn’t run at all, even after creating a start function just to see if I could see if it could print me a text in the debug log.

I somehow fixed the problem by creating a new script with a different name, but with the exact same code.

And yes I linked the script to an empty gameobject.

Can anyone explain how or why it happened? It took me quite some time to work around the problem.
Is the scriptname “taken” or something?

This is the code I used in the script that didn’t work:

using UnityEngine;
using System.Collections;

public class WaveSpawner : MonoBehaviour{

    public Transform enemyPrefab;
    public float timeBetweenWaves = 5f;

    private float countdown = 0.5f;

    void update() { 
        if (countdown <= 0)
        {
            SpawnWave();
            countdown = timeBetweenWaves;
        }

        countdown -= Time.deltaTime;
    }

    void SpawnWave()
    {
        Debug.Log("Wave incoming!");
    }
}

And here the code for the script that does work:

using UnityEngine;
using System.Collections;

public class WaveSpawner1 : MonoBehaviour {

    public Transform enemyPrefab;
    public float timeBetweenWaves = 5f;

    private float countdown = 2f;
	
	void Update () {
        if (countdown <= 0)
        {
            SpawnWave();
            countdown = timeBetweenWaves;
        }

        countdown -= Time.deltaTime;
    }

    void SpawnWave()
    {
        Debug.Log("Wave incoming!");
    }
}

those scripts are not the same. update() is NOT the same as Update(). Unity will call the latter automatically, not the former…

also, make sure that the filename is the same as the class name.