Hello.
Alright, so i was following someones code for creating a toggable flashlight.
I'm fairly new to coding, so i'm not 100% sure on how to manage this.
I want to make it so the linkgun has a toggable flashlight on it.
All i did was stick this in its own class, give the linkgun the light socket (not sure if i did it right), and test it out in game, but to no avail.
If someone could point me in the right direction or let me know how to implement it, i would appreciate it.
Here is the code for reference.
Alright, so i was following someones code for creating a toggable flashlight.
I'm fairly new to coding, so i'm not 100% sure on how to manage this.
I want to make it so the linkgun has a toggable flashlight on it.
All i did was stick this in its own class, give the linkgun the light socket (not sure if i did it right), and test it out in game, but to no avail.
If someone could point me in the right direction or let me know how to implement it, i would appreciate it.
Here is the code for reference.
Code:
class FlashLightPawn extends UTPawn; //change to extend Pawn or UDKPawn if you want but give it a skelital mesh with a reference variable called Mesh
var SpotlightComponent Light; //the actual light
var name Light_Socket; //the name of the socket to attach to
var bool LightsOn; // boolean to turn light on and off
//use a keybind in UDKGame/Config/DefaultInput.ini
exec function LightOn()
{
//alternate between true and false
LightsOn = !LightsOn;
//if true attach the light
if (LightsOn)
{
//if you want it to be on the weapon use Weapon.Mesh.AttachComp.....
Mesh.AttachComponentToSocket(Light, Light_Socket);
//set up its properties (these properties were almost from a post on here, cant remember who from)
Light.LightShadowMode = LightShadow_Normal;
Light.ShadowFilterQuality = SFQ_Medium;
Light.ShadowProjectionTechnique = ShadowProjTech_BPCF_Medium;
//subtlle light shaft to simulate some kind of flashlight corona
Light.bRenderLightShafts = true;
Light.BloomScale = 0.2;
Light.RadialBlurPercent = 1;
}
else if (!LightsOn) //false so detach the light
{
Mesh.DetachComponent(Light);
}
}
DefaultProperties
{
//declare the light component
Begin Object class=SpotLightComponent Name=MyLightComponent
InnerConeAngle=10
OuterConeAngle=26.2
Radius=92000
Brightness=2.00000
LightShaftConeAngle=89
//bRenderLightShafts=true
LightColor=(R=141,G=247,B=155)
CastShadows=true
CastStaticShadows=False
CastDynamicShadows=True
bCastCompositeShadow=False
bAffectCompositeShadowDirection=False
End Object
//get a reference to the object
Light=MyLightComponent
//the name of the socket
Light_Socket="LightSocket"
}