Game Development Community

Turning a light on and off

by Caleb · in Technical Issues · 06/01/2007 (7:51 am) · 2 replies

Hi all. I've come across a problem when I try to toggle my light on and off, I was using:
function volumeLight::enable(%this)
{
   %this.setEnable(true);
   %this.setScale(%this.getScale());
}
and,
function volumeLight::disable(%this)
{
   %this.setEnable(false);
   %this.setScale(%this.getScale());
}
To toggle my lights on and off.

As a test, I drop the swinging light from starter.fps kit into the world, gave it a name, and toggled it on and off a few times to make sure it worked. Everything worked great until I saved the mission, quit, and came back in. Now the lights won't turn on and off! The only way for me to toggle a light, is to create a new one ever time I load the mission.

Is there something I'm missing? Is there a better way to toggle a light?
Please help!

#1
06/06/2007 (3:53 pm)
Are there any errors in the console after calling enable/disable on the object? It could be that either the object script reference or name points to the wrong or an invalid object, or the method is not valid for the object referenced (in the code that calls enable/disable).
#2
06/07/2007 (6:03 am)
Thanks for the reply John.

As it turns out, the volume light that I was using, was a static light. I've now added a dynamic light, and all works fairly well.