Announcement

Collapse
No announcement yet.

Framedrop Flashlight

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Framedrop Flashlight

    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))

    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
    }

    #2
    What type of hardware are you using? I'm guessing your flashlight is using dynamic shadows, that can be very taxing on a system, typically not too much for one light but if you don't have a very powerful system then the effects could be high.

    Comment


      #3
      Hi, and thanks for your help. I do believe that I got a good enough computer to handle this sort of thing. I'll try to get my specs..! *walks away.. sort of*
      Ok.. I think I found something you might help me with.

      System Model: GT680/GX680/GT683/GT683DX
      BIOS: MSI GT683 E16F2IMS Ver:1.0M 05/12/2011 MSI-Notebook
      Processor: Intel(R) Core(TM) i5-2410M CPU @ 2.30GHz (4 CPUs), ~2.3GHz
      Memory: 6144MB RAM
      User DPI Setting: 96 DPI (100 percent)

      Chip type: GeForce GTX 560M
      Display Memory: 4048 MB
      Dedicated Memory: 1488 MB
      Shared Memory: 2560 MB
      Current Mode: 1920 x 1080 (32 bit) (59Hz)

      If you need more numbers, let me know! Thanks

      Comment

      Working...
      X