- Home /
Seperate switches for individual lights
Hi, I'm new to scripting and I'm having trouble getting something to work... I've set up a raycast from the centre of the screen which I'm wanting to use to activate a spotlight when the camera is facing the object which the light is focussed on. I'm using the script:*
var lightswitch : Transform;
function Update () { if (raycast.rayhit == true) { lightswitch.light.enabled = true; }
else
{ lightswitch.light.enabled = false;
} }
Ive assigned this script to various objects with box colliders set as triggers and assigned the corresponding light to the lightswitch variable.
My problem is that when the raycast hits one trigger all the lights come on together.
What change to my script is needed to seperate the lights out so that ONLY the corresponding light is activated when it's trigger is hit?
Thanks
Your answer