- Home /
unknown identifier
i have a script, that is a component to a light switch model, to turn lights on and off. i have a class set up as a list to allow multiple lights to be paired. The sample script is here:
import System.Collections.Generic;
var lights : List.<Lightsoi> = List.<Lightsoi>();
var Material1 : Material;
var Material2 : Material;
var switchoi : GameObject;
public class Lightsoi {
var shine : Light;
}
function Update()
{
var fwd = transform.TransformDirection (Vector3.forward);
if (Physics.Raycast (transform.position, fwd, 10))
{
var mat : boolean = false;
mat = !mat;
if(mat)
switchoi.renderer.material = Material1;
if(!mat)
switchoi.renderer.material = Material2;
if(Input.GetButtonDown("interact"))
{
var on : boolean = false;
on = !on;
if(on)
shine.enabled = true;
if(!on)
shine.enabled = false;
}
}
}
shine is the light variable, and on lines 29, and 31, i get an error saying
andAssets/Standard Assets/Scripts/General Scripts/Switches.js(29,25): BCE0005: Unknown identifier: 'shine'.
Assets/Standard Assets/Scripts/General Scripts/Switches.js(31,25): BCE0005: Unknown identifier: 'shine'.
can someone tell me how to fix this?
This bit:
public class Lightsoi {
var shine : Light;
}
You're declaring a tiny, one-variable class which doesn't appear to be used. The variable "shine" isn't in scope because it's in that tiny class.
You probably want "shine" to exist in your outer scope. Get rid of the class. It should just look like this:
var shine : Light;
Or,
lights.Add(new Lightsoi());
//and call using
lights[0].shine
Your answer
Follow this Question
Related Questions
BCE0005: Unknown identifier: 'transform' 2 Answers
HealthPack Script Problem... 1 Answer
Error BCE0005: Unknown identifier: 'GetAxis'. 0 Answers
Error BCE0005: Unknown identifier: 'GetAxis'. 0 Answers
how to fix unknown identifier? 1 Answer