- Home /
Load New Scene After Player Death?
Hi, I have a script which if the player collides with the enemy, the player dies. After the player dies, I want to load a like a game over screen which I have created. How do I load this game over screen when the player dies? My game over scene is called "DeathSequenceScene". I know a bit of Application.LoadLevel stuff, so can anyone add that function onto this script? Many thanks.
function OnTriggerEnter(other: Collider){
if (other.tag == "Player"){
Destroy(other.gameObject);
}
}
Have a go first and let us correct it if you get it wrong, ins$$anonymous$$d :)
AliA$$anonymous$$han's reply
function OnTriggerEnter(other: Collider){
if (other.tag == "Player"){
Destroy(other.gameObject);
}
}
function Update(){
if (other.tag == "Player"){
Destroy(other.gameObject)= true
Application.LoadScreen ("DeathSequenceScene");
}
}
I'm not sure but yeah:/ need help!
Answer by Geckoo1337 · Sep 19, 2013 at 04:18 PM
I think you're wrong. This function you mention is related to the trigger, not the sequence of death or loading. We need to create another function and charge level :
function Die () {
// Disable all script behaviours (Essentially deactivating player control)
var coms : Component[] = GetComponentsInChildren(MonoBehaviour);
for (var b in coms) {
var p : MonoBehaviour = b as MonoBehaviour;
if (p)
p.enabled = false;
}
WaitForSeconds(2);
Application.LoadLevel (1); <<< gameover screen or scene
}
Your answer
Follow this Question
Related Questions
Death Screen? 1 Answer
Controller Collision Load Scene 2 Answers
Load a scene after 3 deaths and show the score 2 Answers
Load New Scene On Collision. 1 Answer
Scene Load Issues 1 Answer