Load a scene after 3 deaths and show the score

Hey there, just wondering if I can get a few tips on sorting my problem out.
Anyway, I got a script that makes me respawn when I die so I can respawn all the time but I wanna fix it so after 3 deaths It will load a new scene that shows me the score I got…
I got the scripts for the scores so I can see it ingame but not on a new scene. I want it to load a new scene after 3 deaths and show me the score I got then. So my problems is that I want it to load a new scene after 3 deaths and then show me the score I got.

is it even possible to load a scene after 3 deaths and show the score I got ( thru the GUI ) ?

Well, Here is the scrip I’m using to respawn when I die:


pragma strict
pragma downcast

var checkpoint : Transform;

function OnSignal () {
transform.position = checkpoint.position;
transform.rotation = checkpoint.rotation;

ResetHealthOnAll ();

}

static function ResetHealthOnAll () {
var healthObjects : Health = FindObjectsOfType (Health);
for (var health : Health in healthObjects) {
health.dead = false;
health.health = health.


don't use '3' as a tag. also, you don't need to say the same thing with 5 different versions of wording.

The for is incomplete

also, I might be mistaken, but don't you need # in front of pragma? does this script even work or does it give you errors all over the place?

2 Answers

2

it’s totally possible.

custom google for counter, loadlevel, dontdestroyonload and scoreboard and write a script for it. Rock on.

Greetz, Ky.

The easiest way is to use static vars - they are created when the program begins, and survive until you exit the game. You can have a Control.js script, for instance, attached to the player, where you count lives and score - something like this:

static var life: int = 3;
static var score: int = 0;

function Update(){
    if (life <= 0){ // if life reached 0 load level ShowScore
        Application.LoadLevel("ShowScore");
    }
}

You can access life and score from any other script as Control.life and Control.score When the player dies, decrement the variable Control.life. When getting points, add them to Control.score.

In the ShowScore level, read these variables and show them with GUIText or GUI.Label.