Game Development Community

Turn SpotLight on and off when enter and exit trigger (1.1Beta3)

by Ray Taylor · in Torque 3D Professional · 02/06/2011 (1:22 pm) · 2 replies

I have a SpotLight(LightOver1) that is off (isEnabled = "0") on game start up. I want it to come on when entering trigger:

function Earth1RevOrGen::onEnterTrigger( %this, %trigger, %obj )
{
//this trigger does other things also but removed them for this posting
WHAT GOES HERE? Something like?: LightOver1.isEnabled = "1";
}

function Earth1RevOrGen::onLeaveTrigger( %this, %trigger, %obj )
{
//this trigger does other things also but removed them for this posting
WHAT GOES HERE? Something like?: LightOver1.isEnabled = "0";
}

This is the Spotlight creation in the .mis file:
new SpotLight(LightOver1) {
range = "10";
innerAngle = "30";
outerAngle = "40";
isEnabled = "0"; //off on startup
color = "0.776471 0.729412 0.776471 1";
brightness = "0.25";
castShadows = "0";
priority = "1";
animate = "0";
animationPeriod = "1";
animationPhase = "1";
flareScale = "1";
attenuationRatio = "0 1 1";
shadowType = "Spot";
texSize = "512";
overDarkFactor = "2000 1000 500 100";
shadowDistance = "400";
shadowSoftness = "0.25";
numSplits = "1";
logWeight = "0.91";
fadeStartDistance = "0";
lastSplitTerrainOnly = "0";
representedInLightmap = "0";
shadowDarkenColor = "0 0 0 -1";
includeLightmappedGeometryInShadow = "0";
position = "220.1 -258.523 105.938";
rotation = "1 0 0 100";
canSave = "1";
canSaveDynamicFields = "1";
};

Seems so simple but can't find the answer any place (search not working too well, even google search). Can it be done with a simple statement or do you need to write and call a separate function?

#1
02/06/2011 (1:55 pm)
You can see a list of functions from an object if you "dump" it's name or IDnumber in the console.

mylight.dump();

And from that list you'd use:
void    setlightenabled( bool state )

Which in-game works as:
mylight.setlightenabled(1);
1/true for on, 0/false for off.
#2
02/06/2011 (2:55 pm)
Steve, thanks, light works great on/off. I learned how to find the info on my own now with the dump function. Thanks for the assistance.