I'm looking to trigger a public bool setup in a LevelManager Script from another script.
so when something happens on script B, the bool in script A switches to true.
Below, are 2 scripts where levelRestart.cs is a trigger, when a player hits, it needs to access the public bool in the LevelManager script and say startGame
is true.
Can someone help?
LevelManager.cs
public bool startGame = false;
void Update ()
{
if (startGame == true)
{
SpawnKonyaku();
startGame = false;
}
}
LevelRestart.cs
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.tag == "Player")
{
levelManager.startGame = false; //<- This is where, i need help
}
}
RestartLevel Script to trigger public bool startGame to be true