x


Why Unknown identifier?

Hi guys. I'm trying write restart game code when something hit the floor:

function Start(){
    var thisLevel : int= Application.loadedLevel;
    print(thisLevel);
}

function OnTriggerEnter (other : Collider) {
    Application.LoadLevel (thisLevel);
}

I got: Assets/-MyScripts/RestartLevel-1.js(7,32): BCE0005: Unknown identifier: 'thisLevel'. Why 'thisLevel' is unknown?

thanks for any answer

more ▼

asked Jan 09 '11 at 09:57 AM

kecaj gravatar image

kecaj
30 8 8 9

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

1 answer: sort voted first

You are declaring "thisLevel" in the local scope of the start function and the variable does not exist anywhere else.

Try the following:

var thisLevel : int;

function Start(){
    thisLevel = Application.loadedLevel;
    print(thisLevel);
}

function OnTriggerEnter (other : Collider) {
    Application.LoadLevel (thisLevel);
}
more ▼

answered Jan 09 '11 at 10:20 AM

bjarnefisker gravatar image

bjarnefisker
237 1 2 12

(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:

x263
x70
x18

asked: Jan 09 '11 at 09:57 AM

Seen: 1936 times

Last Updated: Jan 09 '11 at 10:06 AM