Question by
lahc22 · Feb 06, 2017 at 08:41 AM ·
3dlivesendgamegamecontroller
How do you add player lives and end the game?
I'm making a top down shooter - I already checked out Unity's tutorial on making the game end and it didn't work. In the tutorial they have Enemy spawner codes inside the Game Manager script, for mine, I have the Game Manager and Enemy Spawner script separate. The tutorial makes a code that relates to both so it was confusing.
Here's my Game Controller: This is where I would put the code for respawning, losing lives, and ending the game, right?
public class GameController : MonoBehaviour
{
public GUIText scoreText;
public int score;
// Use this for initialization
void Start ()
{
score = 0;
UpdateScore();
}
public void AddScore (int newScoreValue)
{
score += newScoreValue;
UpdateScore();
}
// Update is called once per frame
void UpdateScore ()
{
scoreText.text = "Score: " + score;
}
}
Comment
Your answer
Follow this Question
Related Questions
Lifes count resets with level 0 Answers
end game when multiple scores all hit zero 2 Answers
UCE0001 even though i got the semicolon right (i think) 1 Answer
Helppp meee about making Cube... Urgent... 1 Answer
Shooting enemy to spawn them 0 Answers