Hi, ih have a cube object that is invisible, because its a trigger.
To this cube (trigger) I have attached a Spotlight, named “RedSpotlight”.
In my script TriggerCollider.js I have write down some lines of code.
My problem is how to get the attached light. The script is a component of the cube trigger.
#pragma strict
private var redlight : Light;
function Start () {
redlight = GetComponent("RedSpotlight");
}
function Update () {
}
function OnTriggerEnter ()
{
Debug.Log("TriggerEnter");
redlight.enabled = true;
}
function OnTriggerStay ()
{
Debug.Log("TriggerStay");
redlight.enabled = true;
}
function OnTriggerExit ()
{
Debug.Log("TriggerExit");
redlight.enabled = false;
}
Instead of GetComponent(“RedSpotlight”); I have also tried gameObect.GetComponent(“RedSpotlight”); and this.GetComponent(“RedSpotlight”);