game over screen
i need a game over screen on my game. but it says that game is over while i still playing the game. but when my life becomes zero then the "Game Over" text disappears. can you please help me on this. i'm freaking out!
Comment
Answer by TrueMaskss786 · Aug 06, 2016 at 07:15 AM
can you just show the code where you are getting problem
Answer by glady · Aug 06, 2016 at 07:43 AM
hi @TrueMaskss786 this is my code
using UnityEngine; using UnityEngine.SceneManagement; using System.Collections; using UnityEngine.UI; public class lifelost : MonoBehaviour {
public GameObject over;
public int life;
public Text lifeText;
// Use this for initialization
void Start()
{
over = GameObject.Find("gameover.Unity");
SetCountText();
}
void OnClickWrong()
{
life -= 1;
}
// Update is called once per frame
void Update()
{
if (life == 0)
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
public void LifeLost(int lifeMinus)
{
life -= lifeMinus;
SetCountText();
}
void SetCountText()
{
lifeText.text = "Life : " + life.ToString();
}
}
Your answer
Follow this Question
Related Questions
game over script 0 Answers
Show picture when object is hit 0 Answers
How to pause stopwatch when player enters game over scene? 0 Answers