- Home /
Question by
ThomasMarsh · Jan 04, 2015 at 05:15 PM ·
activelightsonoff
Lights wont turn back on
I am having an issue with lights not being able to be active after I have made them unactive. The way I am "turning on" and "turning off" the lights is using these lines of code:
gameObject.light.active = false; //Off
gameObject.light.active = true; //On
The off line works perfectly, however, when I try to turn them on it does not work. Does anyone know why this is happening?
Comment
Best Answer
Answer by Mmmpies · Jan 04, 2015 at 05:29 PM
Well I'm using C# and I got this working earlier:
public bool BeenTriggered;
public GameObject WarningLight;
...
if(BeenTriggered)
{
WarningLight.SetActive(true);
}
else
{
WarningLight.SetActive(false);
}
the bool is public as it's triggered from a different script. I just drag the light onto the public slot but however you access the gameObject should be fine.
Hope it helps
Your answer
Follow this Question
Related Questions
Turn on/off Script 3 Answers
Turn On and Off Lights Via Script 1 Answer
Particle system turns on when player gets close. 1 Answer