- Home /
to load gameover scene when life is equal to null
i had a script, whereby, whenever i hit a game object it loses life, but i want a situation that when the life bar reaches zero, i should be able to load my gameover scene. this is the script below..i need help please...and sorry for my poor english..
pragma strict
var pick : AudioClip;
function OnTriggerEnter(col:Collider){
if(col.gameObject.tag=="timi"){
//play sound Debug.Log("HHHHHH"); col.gameObject.SendMessage("LooseLife"); audio.PlayOneShot(pick); Destroy(gameObject); }
}
Comment
Answer by Dblfstr · Mar 13, 2014 at 01:55 PM
var pick : AudioClip;
function OnTriggerEnter(col:Collider){
if(col.gameObject.tag=="timi"){
//play sound
Debug.Log("HHHHHH");
col.gameObject.SendMessage("LooseLife");
audio.PlayOneShot(pick);
Destroy(gameObject); }
//Check the value of life
//If zero:
//Application.LoadLevel( Game Over Scene );
//Or
//Application.LoadLevelAdditive( Game Over Scene );
//If you want the gameover stuff on top of you current scene.
}
Your answer
Follow this Question
Related Questions
problem count life of the player. 2 Answers
How To Show Score On End Game 1 Answer
How do I add a Game Over text to my timer? 1 Answer
turning script on after time 2 Answers
Player Health Not Working? 4 Answers