How to make dynamic light for Flashlight?
by ChrisG · in Torque Game Engine Advanced · 09/14/2008 (1:45 am) · 18 replies
I'm trying to make a flashlight that can be attached to the player. So far I've taken a headlight from Brit Scott's Battle Frog vehicle and attached it to the player, but I'm only getting the flashlight 'shine' and not the spot (which is the bit that I really need).

The code I've used for the sgUniversalStaticLightData datablocks is straight out of the battle frog resource: www.garagegames.com/blogs/72186/15382
I need to flashlight to light up both DIF and DTS models.
Is TGEA able to make flashlight like this and if so is there a resource or a thread that explains how?

The code I've used for the sgUniversalStaticLightData datablocks is straight out of the battle frog resource: www.garagegames.com/blogs/72186/15382
I need to flashlight to light up both DIF and DTS models.
Is TGEA able to make flashlight like this and if so is there a resource or a thread that explains how?
About the author
Currently working on ZDay: www.zdaygame.com
#2
09/14/2008 (12:14 pm)
I did attach the same lights to the player in TGE. Maybe look through or post your console log?
#3
Have you tried it in TGEA? I wondering if it might be TGEA problem.
09/14/2008 (4:12 pm)
Ok - I've had a look through the console log. I couldn't see anything in it that looks like the problem. I can't post the log it's too big for the forum post character limit. If you think it would help I can email it to you.Have you tried it in TGEA? I wondering if it might be TGEA problem.
#4
edit, you may want to try sgMountLight
09/14/2008 (5:07 pm)
Check your lighting datablock to make sure its the same as one of the ones in tgea. Some of the lighting datablocks have changed.edit, you may want to try sgMountLight
#5
I tried changing the datablock sgMountLight and it didn't change anything in game.
Also, when the light is being created is there any reason that the datablock is defined twice?
and here's where I attach them to the player
09/14/2008 (7:32 pm)
Ok here's what I'm using. One change that I've made from battle frog is to separate LeftHeadLightShine and LeftHeadLightSpot datablocks into separate files.I tried changing the datablock sgMountLight and it didn't change anything in game.
Also, when the light is being created is there any reason that the datablock is defined twice?
datablock sgUniversalStaticLightData(LeftHeadLightShine) {
canSaveDynamicFields = "1";
Enabled = "1";
LightOn = "1";
Radius = "5.85";
Brightness = "0.37931";
Colour = "1 0.976471 0.941177 1";
FlareOn = "0";
FlareTP = "1";
FlareBitmap = "common/lighting/corona";
FlareColour = "1 1 1 1";
ConstantSizeOn = "0";
ConstantSize = "0.4";
NearSize = "0.4";
FarSize = "1.6";
NearDistance = "3";
FarDistance = "15";
FadeTime = "0.1";
BlendMode = "0";
AnimColour = "0";
AnimBrightness = "0";
AnimRadius = "0";
AnimOffsets = "0";
AnimRotation = "0";
LinkFlare = "1";
LinkFlareSize = "0";
MinColour = "0 0 0 1";
MaxColour = "1 0.976471 0.941177 1";
MinBrightness = "0";
MaxBrightness = "0.37931";
MinRadius = "0.1";
MaxRadius = "5.85";
StartOffset = "-5 0 0";
EndOffset = "5 0 0";
MinRotation = "0";
MaxRotation = "359";
SingleColourKeys = "1";
RedKeys = "AZA";
GreenKeys = "AZA";
BlueKeys = "AZA";
BrightnessKeys = "AZA";
RadiusKeys = "AZA";
OffsetKeys = "AZA";
RotationKeys = "AZA";
ColourTime = "5";
BrightnessTime = "5";
RadiusTime = "5";
OffsetTime = "5";
RotationTime = "5";
LerpColour = "1";
LerpBrightness = "1";
LerpRadius = "1";
LerpOffset = "1";
LerpRotation = "1";
StaticLight = "0";
SpotLight = "1";
SpotAngle = "120";
AdvancedLightingModel = "1";
EffectsDTSObjects = "1";
castsShadows = "1";
DiffuseRestrictZone = "1";
AmbientRestrictZone = "0";
LocalAmbientAmount = "0";
SmoothSpotLight = "1";
DoubleSidedAmbient = "0";
LightingModelName = "SG - Original Stock (Lighting Pack)";
//lightingModelName = "Inverse Square";
UseNormals = "1";
SupportedFeatures = "NoSpecCube";
MountPoint = "0";
MountPosition = "0 0 0";
MountRotation = "0.980581 0 -0.196116 99.6599";
};datablock sgUniversalStaticLightData(LeftHeadLightSpot) {
canSaveDynamicFields = "1";
Enabled = "1";
LightOn = "1";
Radius = "5.85";
Brightness = "0.727273";
Colour = "1 0.976471 0.941177 1";
FlareOn = "0";
FlareTP = "1";
FlareColour = "1 1 1 1";
ConstantSizeOn = "0";
ConstantSize = "0.4";
NearSize = "0.4";
FarSize = "1.6";
NearDistance = "3";
FarDistance = "15";
FadeTime = "0.1";
BlendMode = "0";
AnimColour = "0";
AnimBrightness = "0";
AnimRadius = "0";
AnimOffsets = "0";
AnimRotation = "0";
LinkFlare = "1";
LinkFlareSize = "0";
MinColour = "0 0 0 1";
MaxColour = "1 0.976471 0.941177 1";
MinBrightness = "0";
MaxBrightness = "0.727273";
MinRadius = "0.1";
MaxRadius = "5.85";
StartOffset = "-5 0 0";
EndOffset = "5 0 0";
MinRotation = "0";
MaxRotation = "359";
SingleColourKeys = "1";
RedKeys = "AZA";
GreenKeys = "AZA";
BlueKeys = "AZA";
BrightnessKeys = "AZA";
RadiusKeys = "AZA";
OffsetKeys = "AZA";
RotationKeys = "AZA";
ColourTime = "5";
BrightnessTime = "5";
RadiusTime = "5";
OffsetTime = "5";
RotationTime = "5";
LerpColour = "1";
LerpBrightness = "1";
LerpRadius = "1";
LerpOffset = "1";
LerpRotation = "1";
StaticLight = "0";
SpotLight = "1";
SpotAngle = "120";
AdvancedLightingModel = "1";
EffectsDTSObjects = "1";
castsShadows = "1";
DiffuseRestrictZone = "0";
AmbientRestrictZone = "0";
LocalAmbientAmount = "0";
SmoothSpotLight = "1";
DoubleSidedAmbient = "0";
//lightingModelName = "Inverse Square";
LightingModelName = "SG - Original Stock (Lighting Pack)";
UseNormals = "1";
SupportedFeatures = "NoSpecCube";
MountPoint = "0";
MountPosition = "0 0 0";
MountRotation = "-1 0 0 80";
};and here's where I attach them to the player
%light = new volumeLight()
{
dataBlock = "LeftHeadLightShine";
rotation = "-0.357694 0.933839 9.9834e-009 180";
scale = "1 1 1";
dataBlock = "LeftHeadLightShine";
Enable = "1";
IconSize = "1";
ParticleColorAttenuation = "1";
Texture = "common/lighting/lightFalloffMono.png";
lpDistance = "0.75"; ////REF: was 0.35
ShootDistance = "15"; ////REF: was 5
Xextent = "0.6";
Yextent = "0.6";
SubdivideU = "4";
SubdivideV = "4";
FootColour = "1.000000 1.000000 1.000000 0.182000";
TailColour = "0.000000 0.000000 0.000000 0.000000";
};
%light.attachtoobject(%player);
%light = new volumeLight()
{
dataBlock = "LeftHeadLightSpot";
//dataBlock = "sgMountLight";
rotation = "-0.357694 0.933839 9.9834e-009 180";
scale = "1 1 1";
dataBlock = "LeftHeadLightSpot";
//dataBlock = "sgMountLight";
Enable = "1";
IconSize = "1";
ParticleColorAttenuation = "1";
//Texture = "common/lighting/lightFalloffMono.png";
lpDistance = "0.35";
ShootDistance = "10";//Ref: was 5
Xextent = "0.6";
Yextent = "0.6";
SubdivideU = "4";
SubdivideV = "4";
FootColour = "1.000000 1.000000 1.000000 0.182000";
TailColour = "0.000000 0.000000 0.000000 0.000000";
};
%light.attachtoobject(%player);
#6
09/15/2008 (12:06 am)
The light datablock doesn't need to be defined twice... I at least see in "LeftHeadLightSpot" it should be, SpotLight = "0"; If all else fails, delete DSO's, try it again. If nothing happens email me the console, stacalkas_nomen@hotmail.com I would send you my mech's cs file since it's based on a player, but I went it through today. I changed a bunch of code, so I could switch the light on/off.
#7
09/15/2008 (2:53 pm)
@Britt: I emailed you a copy of the console
#8
09/16/2008 (1:04 am)
Thanks, I got it. I'll see what happens in the TGEA demo.
#10
I'm going to pull out all my lighting datablocks and start again with the stock tgea lights to see if that makes a difference. I'll keep adding to this thread as I make progress or lose hair.
09/16/2008 (4:27 am)
Thanks for your help here Britt, unfortunately its still not working - again I get the shine but not the spot.I'm going to pull out all my lighting datablocks and start again with the stock tgea lights to see if that makes a difference. I'll keep adding to this thread as I make progress or lose hair.
#11
09/16/2008 (11:39 am)
Can you confirm that it works for Kork in the Stronghold example, mission barebones? It may be possible it's something in your level or your player.
#12
Are you sure there's no other code somewhere that I'm missing?
09/17/2008 (12:20 am)
I don't have a TGEA license so I've only got the Barricade Demo. I attached the light to the BoomBot by copying the 2 light datablocks and attaching the lights in the onAdd method in player.cs, got the shine but still no spot light.Are you sure there's no other code somewhere that I'm missing?
#13
09/17/2008 (1:56 am)
While I'm downloading the barricade demo... Go to the console and type(if you called it flashLightSpot): "flashLightSpot.dump();" if it works then we know the light data is ok.
#14
09/17/2008 (8:25 pm)
FlashLightSpot.dump(); Worked OK - so the datablock is loading in ok
#15
09/17/2008 (11:17 pm)
Chris sent you another email
#16
09/18/2008 (8:13 pm)
I have it done in TGEA. You have to set the texture for the spot to make it visible.
#17
01/19/2010 (7:56 pm)
Are you having the problem because the light works fine on the terrain mesh, but it's not working on interiors?
#18
The flashlight beam still needs a bit of work and we were having issues with the light appearing on the other side of walls and flickering on the other side of portals.
01/19/2010 (10:52 pm)
One of our programmers (Dan) managed to get this working. I'm not entirely sure what he did to the script to fix it but he did say that one of the lights was pointing in the wrong direction.The flashlight beam still needs a bit of work and we were having issues with the light appearing on the other side of walls and flickering on the other side of portals.
Associate Britt Scott