waweConfigs - Error

I wrote everything identical as it was in the video, i also re-write all the codes and made the project by zero following again all the videos, but as soon ad i create this EnemySpawner.cs file, once I reach the 9.55 minute in the 99th lesson, i get this following error:
“Assets\Scripts\EnemySpawner.cs(12,27): error CS1955: Non-invocable member ‘EnemySpawner.waweConfigs’ cannot be used like a method.”
And the following is all the code for the EnemySpawner.cs file:

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

public class EnemySpawner : MonoBehaviour
{
[SerializeField] List waweConfigs;
int startingWawe = 0;
// Start is called before the first frame update
void Start()
{
var currentWawe = waweConfigs(startingWawe); //Here is where the error is underlined by the visual studio program: “waweConfigs”
StartCoroutine(SpawnAllEnemiesInWawe(currentWawe));
}

private IEnumerator SpawnAllEnemiesInWawe(WaweConfig waweConfig)
{
    Instantiate(
        waweConfig.GetEnemyPrefab(),
        waweConfig.GetWaypoints()[0].transform.position,
        Quaternion.identity);
    yield return new WaitForSeconds(waweConfig.GetTimeBetweenSpawns());
}

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

}


It looks like you are trying to use the waweConfigs object like a function which is what the error is about.

So instead of

var currentWawe = waweConfigs(startingWawe); //Here is where the error is underlined by the visual 

try this :

var currentWawe = waweConfigs[startingWawe];  //basically use square brackets inplace of round brackets.
1 Like

codermonk is right

When you see errors like these (or you have a code problem in general), you can first try to compare your code to the one on Github. Each lecture has a “Resources” button in Udemy, click that, then click “Lecture Project changes”. Scroll down until you find the file you have a problem with and see what’s different.

I try to use the git hub stuff, but i don’t understand how it works, i see random stuff that don’t look like a code.


does not look like the code that is shown in the course.

Thank you very much, but why in the course they tell us to put round brackets and not square?
In the course the techer is using the 2018 Unity version whyle i’m using the 2020 one.

Did you scroll down to check out the other files that are there?
Also, the Unity version does not matter. In what Lecture did the instructor say to use round brackets?

  1. but why in the course they tell us to put round brackets and not square?

I highly doubt that , I dont recall the exact video but it may have just been a misunderstanding…the code on github has square brackets as you can see.

  1. I try to use the git hub stuff, but i don’t understand how it works, i see random stuff that don’t look like a code.

That is because you are viewing the contents of a prefab file and not a csharp code file.

Also instead of trying to view the code files on github one by one you can use the Download zip button as shown and get the whole thing and run and check out their version of the full game on your computer.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms