Hello there..! We have a flashlight in our game that is causing a frame rate drop around 15 - 30... It is really annoying and I barely know anything about optimizing lighting etc.
Here's the code for it.. ((there are 2 lights spawning))
Here's the code for it.. ((there are 2 lights spawning))
Code:
class ProtOneFlashlight extends Actor notplaceable; var ProtOneLight OuterLight, InnerLight; var bool bEnabled; var bool bOn; var ProtOnePawn pPawn; var vector PositionOffset; var float BobDamping; var ProtOneAudioComponent FlashlightSound; // Audio component for playing the clicking flashlight sound simulated function PostBeginPlay() { super.PostBeginPlay(); } function InitializeLights(ProtOnePawn pawn) { pPawn = pawn; InnerLight = spawn(class'ProtOneLight', pawn); InnerLight.SetBase(pawn); InnerLight.LightComponent.SetEnabled(false); InnerLight.LightComponent.SetLightProperties(3); OuterLight = spawn(class'ProtOneLight', pawn); OuterLight.SetBase(pawn); OuterLight.LightComponent.SetEnabled(false); OuterLight.LightComponent.SetLightProperties(0.05); OuterLight.MainComponent.Radius = 1250.000000; OuterLight.MainComponent.OuterConeAngle = 145; FlashlightSound = spawn(class'ProtOneAudioComponent', self); FlashlightSound.SetSoundCue(SoundCue'ProtOneSound.SFX.FlashlightCue'); PositionOffset =vect(5, -18, 85); } function UpdatePosition(Controller control) { if (bOn) { if (!bEnabled) { InnerLight.LightComponent.SetEnabled(false); OuterLight.LightComponent.SetEnabled(false); bOn = false; } InnerLight.SetRotation(control.Rotation); InnerLight.SetRelativeLocation(pPawn.WeaponBob(BobDamping, BobDamping) + PositionOffset); OuterLight.SetRotation(control.Rotation); OuterLight.SetRelativeLocation(pPawn.WeaponBob(BobDamping, BobDamping) + PositionOffset); } } function Toggle() { if (bEnabled) { FlashlightSound.Play(); if (bOn) { InnerLight.LightComponent.SetEnabled(false); OuterLight.LightComponent.SetEnabled(false); bOn = false; } else { InnerLight.LightComponent.SetEnabled(true); OuterLight.LightComponent.SetEnabled(true); bOn = true; } } } defaultproperties { bOn=false bEnabled=true }
Comment