x


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.


more ▼

asked Sep 07 '11 at 08:46 PM

svettgunnar gravatar image

svettgunnar
16 14 18 20

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

Sep 07 '11 at 08:57 PM SisterKy

The for is incomplete

Sep 07 '11 at 09:12 PM aldonaletto

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?

Sep 07 '11 at 09:18 PM SisterKy
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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 

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.

more ▼

answered Sep 07 '11 at 09:07 PM

aldonaletto gravatar image

aldonaletto
41.5k 16 42 197

(comments are locked)
10|3000 characters needed characters left

it's totally possible.

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

Greetz, Ky.

more ▼

answered Sep 07 '11 at 08:55 PM

SisterKy gravatar image

SisterKy
2.4k 33 41 59

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x718
x436
x274
x71

asked: Sep 07 '11 at 08:46 PM

Seen: 864 times

Last Updated: Sep 07 '11 at 09:18 PM