Question by
ROAMSpider · Jan 12, 2021 at 10:41 PM ·
2d gameend
How does one make a goalpost?
I am making a my first ever game, and need to know how to make a goalpost area.
Essentially, the trigger to spawn a next level. I am using 3 different scripts that should work together, but dont GameManager, EndTrigger, and Level Complete. I also have a UI for when a level's beaten that the button wont work on. any advice is appreciated.
the code to those who need to see it: GameManager:
bool gameHasEnded = false;
public float restartDelay = 1f;
public GameObject completeLevelUI;
public void CompleteLevel ()
{
completeLevelUI.SetActive(true);
}
public void EndGame ()
{
if (gameHasEnded == false)
{
gameHasEnded = true;
Debug.Log("GAME OVER");
Invoke("Restart", restartDelay);
}
}
void Restart ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
This is the LvlComplete:
public void LoadNextLevel ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
And the EndTrigger:
public GameManager gameManager;
void OnTriggerEnter ()
{
gameManager.CompleteLevel();
}
}
Comment
Your answer