- Home /
Changing a bunch of lights intensity
Hi there, I'm trying to change a bunch of lights intensity levels within a time period, however before I can even assign the lights I get an error message saying that the ".intensity" is not a member of the unity engine. This is my script, can anyone fix it?
#pragma strict
var lightaa : GameObject;
var lightab : GameObject;
var lightba : GameObject;
var lightbb : GameObject;
var lightca : GameObject;
var lightcb : GameObject;
lightaa.intensity = 0;
lightab.intensity = 0;
lightba.intensity = 0;
lightbb.intensity = 0;
lightca.intensity = 0;
lightcb.intensity = 0;
function Start ()
{
yield WaitForSeconds(4);
lightaa.intensity = 1.0;
lightab.intensity = 1.0;
yield WaitForSeconds(4);
lightba.intensity = 1.0;
lightbb.intensity = 1.0;
yield WaitForSeconds(4);
lightca.intensity = 1.0;
lightcb.intensity = 1.0;
}
Thank you for your help...
Answer by aditya · Jul 16, 2014 at 05:45 PM
1 : as robertbu said change var lightaa : GameObject; to var lightaa : Light; (All of them) 2 : you are trying to set the light intensity out of any function, i mean change lightaa.intensity = 0; lightab.intensity = 0; lightba.intensity = 0; lightbb.intensity = 0; lightca.intensity = 0; lightcb.intensity = 0;
to
function Awake(){
lightaa.intensity = 0;
lightab.intensity = 0;
lightba.intensity = 0;
lightbb.intensity = 0;
lightca.intensity = 0;
lightcb.intensity = 0;
}
Answer by robertbu · Jul 16, 2014 at 04:50 PM
I assume that all of your 'lightxx' variables are initialized by drag and drop in the Inspector. To fix your problem, you need to make these variables of type 'Light' not type 'GameObject'.
var lightaa : Light;
Note that after making this change, you will need to again drag and drop your lights on to the variables.
Your answer
Follow this Question
Related Questions
photocamera flash 1 Answer
light.intensity shows error 1 Answer
How can I dim light over time? 2 Answers
Starting the game with specific light off 1 Answer
How to turn on a light, then off with the same button. 1 Answer