Load Scene When...

thx for looking into this.
Anyway, I’m using this script to load a scene when my player reach a certain point of health but it’s not working… Can anyone might tell me why or am I doing something wrong here.

Here it is:


if (Health < 1) Application.LoadLeve0(Application.loadedLevel);
function Update ( ) {
}


In the console it says:

Assets/LoadScene.js(1,12): BCE0051: Operator ‘<’ cannot be used with a left hand side of type ‘System.Type’ and a right hand side of type ‘int’.

Don’t really know how to fix this so would be really grateful if someone could help me.

1 Answer

1

the variable “Health” needs to be an integer, if you could post the part where you declare the variable it would help us a lot :slight_smile:

Yeah, that was what i wanted. there's an issue though, the variable you make "public var health : float = 100.0;" is written is small letters, the variable you request in your "if-sentece" is written with a capital "h", when you're scripting you have to be aware that it is case sensitive, so you might want to write "health" instead of "Health" :) if that made any sense :P

is the if-sentence inside the update method in your script?

you can use www.pastebin.com , set the syntax highlightning to javascript :)

if you wanted to paste the entire script in

wow, your code looks so much better than what i write, heh, anyway. start with moving the if-sentence inside the update function, or it wont be run function Update () { if (health < 1 ) Application.LoadLevel(Application.loadedLevel); }