I did a end level but get error

i have a error:

Assets\EndTrigger.cs(9,9): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

i wanted
to log level won when you tuch the cube
with the player

the code (EndTrigger.cs):
using UnityEngine;

public class EndTrigger : MonoBehaviour {

public GameManager gameManager;

void OnTriggerEnter () 

{

    gameManager.CompleteLevel; 

}

}


the refrence(GameManager.cs, frome line 10 to line 13):

using UnityEngine;

using UnityEngine.SceneManagement;

public class GameManager : MonoBehaviour {

bool gameHasEnded = false;

public float restartDelay = 1f;

public void CompleteLevel ()

{

    Debug.Log("Level Won!");

}

public void EndGame ()

{

    if (gameHasEnded == false)

    {

        gameHasEnded = true;

        Debug.Log("GAME OVER");

        Invoke("Restart", restartDelay);

    }

}

void Restart ()

{

    SceneManager.LoadScene(SceneManager.GetActiveScene().name);

}

}


i will glad for help!

*from
public void CompleteLevel ()

to the end of the public void ( { )

Hi @it_gal,

How are you getting on with this? Did you already find a solution?

Maybe the issue is in the OnTriggerEnter method. There are parenthesis missing for the method call:

gameManager.CompleteLevel();

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

Privacy & Terms