Announcement

Collapse
No announcement yet.

Attaching a light to the camera (through out_CamLoc) not working

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

    Attaching a light to the camera (through out_CamLoc) not working

    Hi there!

    I'm stumped right now. I'm doing a couple of tests and I have a trigger. When I press the trigger, the camera is detached from the Pawns eyes socket and moves along a few coordinates that I pre-calculated. This works amazing, no problem there. When the small cutscene is done, the camera is re-attached to the pawn's head.

    The problem is, my map is pitch dark. When you walk around with the Pawn, I have a point light attached to a Pawn's socket, so it functions as kind of an ambient light. Again, this works great. The problem is when I press the trigger and the camera changes behaviour. I've tried to spawn another ambient spot light and have it always be at the same location as the camera, but it's just not working. At all. And I have no idea why! Any help would be amazing! Here is the code:

    Ambient Light Class
    Code:
    class TSAmbLight extends Actor;
    
    var PointLightComponent AmbientLight;
    
    defaultproperties
    {
    	Begin Object Name=PointLightComponent0
    		Brightness=1
    		LightColor=(R=18,G=20,B=18)
    		Radius=3500
    		FalloffExponent=20
    		LightAffectsClassification=LAC_DYNAMIC_AND_STATIC_AFFECTING
    		CastShadows=FALSE
    		CastStaticShadows=FALSE
    		CastDynamicShadows=FALSE
    		bForceDynamicLight=FALSE
    		UseDirectLightMap=FALSE
    		bAllowPreShadow=FALSE
    	End Object
    	AmbientLight=PointLightComponent0
    }
    Pawn Class (I cut out everything that had nothing to do with the camera)
    Code:
    class TSPawn extends SimplePawn;
    
    var TSAmbLight ambient;
    var TSAmbLight cutsceneAmbient;
    
    simulated function PostBeginPlay()
    {
    	ambient = Spawn(class'TSAmbLight',,,Location);
    	Mesh.AttachComponentToSocket(ambient.AmbientLight, 'AMBSocket');
    }
    
    simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
    {
    	if (TSGame(WorldInfo.Game).bCutscene == false)
    	{
    		Mesh.GetSocketWorldLocationandrotation('HeadSocket', out_CamLoc);
    		out_CamRot = GetViewRotation();
    	}
    	else
    	{
    		out_CamLoc = desiredLocation;
    		out_CamRot = desiredRotation;
    
    		if (cutsceneAmbient != NONE)
    		{
    			cutsceneAmbient.SetLocation(out_Loc);
    		}
    		else
    		{
    			cutsceneAmbient = Spawn(class'TSAmbLight',,,out_CamLoc);
    		}
    	}
    
    	return true;
    }
    
    defaultproperties
    {
    }

    #2
    spawn the light once then tell it where to be

    if (cutsceneAmbient == NONE)
    {
    cutsceneAmbient = Spawn(class'TSAmbLight',,,out_CamLoc);
    }
    else
    {
    cutsceneAmbient.SetLocation(out_Loc);
    }

    Comment


      #3
      Hi tegleg, thanks for the reply!

      Isn't that the exact same thing my code does? The only difference is it checks if the cutsceneAmbient is equal to NONE, when on mine it checks if it was already spawned.

      Comment


        #4
        kinda yes, it didnt see the other one in postbeginplay
        im thinking because its called cutsceneAmbient you spawn it when its a cutscene at out_CamLoc.
        then you set its location to out_Loc

        you have another light for normal play, ambient is spawned and attached to the pawn.

        try to use the same light for it all, attachtosocket in normal play, then (possibly Detach()) and set its location in the cutscene
        or if you have to have 2, enable and disable them.

        or it could be a problem in another part of the code that does the switching

        Comment

        Working...
        X