Help what does it mean a guy says it will display a message in the console once - GAME OVER!
bool GamehasEnded = false;
public void EndGame()
{
if (GamehasEnded == false)
{
GamehasEnded = true;
Debug.Log("GAME OVER");
}
}
}
Not sure what your question is, but that should result in a console message only once, assu$$anonymous$$g it gets called at all, and assu$$anonymous$$g nothing else changes the GamehasEnded variable.
You might want to go through this before continuing with Unity: https://unity3d.com/learn/tutorials/topics/scripting/coding-unity-absolute-beginner
Are their multiple instances of the script in your scene? And do you set GamehasEnded anywhere else in the script?
Answer by Happeloy · May 10, 2018 at 07:43 PM
If this method is called, it will print "GAME OVER" in the console. Since there is a boolean that checks if it has been printed before, it will only happen once.
Your answer
Follow this Question
Related Questions
Making achtung die kurve 0 Answers
Discrete Event Simulation + Queuing 0 Answers
Really basic question... 1 Answer
Help making a UMA move 0 Answers
Start() and Update() execution issue 6 Answers