- Home /
Light Switching Unexpected Token Error
Hey guys I keep coming across this unexpected token error and it's doing my head in. A little help would be much appreciated.
I have two lampposts with pointlights each. tagged "Light1" and "Light2" respectively. I want Light1 to be off, but when the light intensity of Light2 becomes 0, which happens in a previous script, I want Light1 to tuen on with intensity of 2.2.
This is my script followed by my error.
#pragma strict
function Start () {
}
function Update () { //when lightoff2 script runs "light2" switches on
var "Light2" light.intensity = 0;)
if
("Light2" light.intensity == 0)
("Light1" light.intensity : float = 2.2);
}
}
Assets/Light2SwitchOn1.js(10,6): BCE0043: Unexpected token: Light2.
Answer by Graham-Dunnett · Dec 04, 2012 at 02:51 PM
Sorry to break the bad news, but your script code is not even remotely correct. It's not valid Javascript. You don't declare variables in Javascript using the names of the lights in quotes. See:
for some help. Create two variables that you can assign your two lights to in the inspector. I am sure some kind soul here will give you more help.
I have only started scripting in the last week so I have a long way to go. Thanks for your honesty and help.