Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Custom Camera Module - Problem with pitch

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

  • Custom Camera Module - Problem with pitch

    Hi there everyone,

    I'm new to scripting/programming with Unreal Script and thought I might start off with getting my head around the camera system.
    So I had a look at the CameraTechnicalGuide and decided to go for the "Custom Camera using modules" approach, since I'm planning to do some more fancy stuff as soon as I get along the with code.
    Now what I did so far is copying the code from the CamTechGuide to get the TopDown camera and then change it into a 3rd person camera.
    I managed to get the camera to circle around the pawn as it rotates but somehow the pitch is still locked (naturally it had to be locked for the TopDown view) which keeps me from continuing.
    I did change the code section which I thought to be responsible for the pawn rotation,...
    In the ControlModule class:
    Code:
    DeltaRot.Pitch = Controller.PlayerInput.aLookUp;
    ...but without any effect. Moving my mouse up and down does make the player model aim up and down, but that seem to be the animation only, since neither the camera nor where the weapon actually fires changes.

    So here is the question: Did anyone use the module approach before? I've mostly seen camera systems using a modified pawn class or a custom camera class, and even though the latter is very similiar I couldn't figure anything out so far. Also browsing through most of the related UDK classes didn't really help.
    The source code of my custom module classes is below,...all other classes are pretty much identical to the CamTechGuide (save the names and directories of my classes of course).
    And I'm pretty sure it's not the camera class who is responsible. I am starting to suspect that my CameraModule isn't even really used by the rest of the code correctly but I don't see how that is possible since both the config and the other classes are done as told in the CamTechGuide.

    So if anyone sees what I'm doing wrong or am overlooking, I'd really appreciate any help!

    CameraModule class:
    Code:
    class DeCameraModule_TopDown extends DeCameraModule;
    
    var float CamAltitude; //actual camera height offset from player
    var float DesiredCamAltitude; //new height offset to move camera to
    var float MaxCamAltitude; //maximum offset from player camera can be
    var float MinCamAltitude; //minimum offset from player camera can be
    var float CamZoomIncrement; //how many units to zoom with each click of mousewheel
    
    //Calculate new camera location and rotation
    function UpdateCamera(Pawn P, DePlayerCamera CameraActor, float DeltaTime, out TViewTarget OutVT)
    {
    	//sin & cos - radian values; 16384 -> 90°; 16384*0.00009587 = ~1,57 = 2PI /4
    	OutVT.POV.Location.Y = P.Location.Y - (sin((P.Rotation.Yaw * 0.00009587)) * 100);
    	OutVT.POV.Location.X = P.Location.X - (cos((P.Rotation.Yaw * 0.00009587)) * 100);
    	OutVT.POV.Location.Z = P.Location.Z + 75;
    	
    	OutVT.POV.Rotation = P.Rotation;
    	OutVT.POV.Rotation.Roll = 0;
    }
    
    //initialize new view target
    simulated function BecomeViewTarget( DePlayerController PC )
    {
       if (LocalPlayer(PC.Player) != None)
          {
          //Set player mesh visible
            PC.SetBehindView(true);
            DePawn(PC.Pawn).SetMeshVisibility(PC.bBehindView);
            PC.bNoCrosshair = true;
          }
    }
    
    function ZoomIn()
    {
       //decrease camera height
       DesiredCamAltitude -= CamZoomIncrement;
       
       //lock camera height to limits
       DesiredCamAltitude = FMin(MaxCamAltitude, FMax(MinCamAltitude, DesiredCamAltitude));
    }
    
    function ZoomOut()
    {
       //increase camera height
       DesiredCamAltitude += CamZoomIncrement;
    
       //lock camera height to limits
       DesiredCamAltitude = FMin(MaxCamAltitude, FMax(MinCamAltitude, DesiredCamAltitude));
    }
    
    defaultproperties
    {
    }
    ControlModule class:
    Code:
    class DeControlModule_TopDown extends DeControlModule;
    
    //Calculate Pawn aim rotation
    simulated singular function Rotator GetBaseAimRotation()
    {
       local rotator   POVRot;
    
       //aim where Pawn is facing - lock pitch
          POVRot = Controller.Pawn.Rotation;
          //POVRot.Pitch = 0;
    
          return POVRot;
    }
    
    //Handle custom player movement
    function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
    {
       if( Controller.Pawn == None )
        {
           return;
        }
    
        if (Controller.Role == ROLE_Authority)
        {
           // Update ViewPitch for remote clients
            Controller.Pawn.SetRemoteViewPitch( Controller.Rotation.Pitch );
        }
    
        Controller.Pawn.Acceleration = NewAccel;
    
    
       Controller.CheckJumpOrDuck();
    }
    
    //Calculate controller rotation
    function UpdateRotation(float DeltaTime)
    {
       local Rotator   DeltaRot, NewRotation, ViewRotation;
    
          ViewRotation = Controller.Rotation;
    
       //rotate pawn to face cursor
          if (Controller.Pawn!=none)
          {
         	 Controller.Pawn.SetDesiredRotation(ViewRotation);
     	  }
    
    	DeltaRot.Yaw   = Controller.PlayerInput.aTurn;
    	DeltaRot.Pitch = Controller.PlayerInput.aLookUp;
    
    	Controller.ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot );
    	Controller.SetRotation(ViewRotation);
    
    	NewRotation = ViewRotation;
    	NewRotation.Roll = Controller.Rotation.Roll;
    	  
    
    	if ( Controller.Pawn != None )
    	{
    		Controller.Pawn.FaceRotation(NewRotation, DeltaTime);
    	}
    }
    
    defaultproperties
    {
    }

  • #2
    The rotation.pitch of the pawn is set to 0 when walking or falling (Pawn::FaceRotation()).
    To get the actual pitch, take a look at:
    Code:
    /** replicated to we can see where remote clients are looking */
    var        const    byte    RemoteViewPitch;
    
    /**
     * Set Pawn ViewPitch, so we can see where remote clients are looking.
     *
     * @param    NewRemoteViewPitch    Pitch component to replicate to remote (non owned) clients.
     */
    native final function SetRemoteViewPitch( int NewRemoteViewPitch );
    This is in Pawn.uc.
    The SetRemoveViewPitch() function is called from PlayerController.

    Comment


    • #3
      Originally posted by slowJusko View Post
      The rotation.pitch of the pawn is set to 0 when walking or falling (Pawn::FaceRotation()).
      Thanks, it's good to know that for fact.
      I had a look at the SetRemoteViewPitch() function but didn't really get anwhere with it yet.

      I found another solution that works for now, even though it doesn't quite feel like good style to me...
      I'm currently using this in my custom camera module:
      Code:
      OutVT.POV.Rotation.Pitch = PlayerCamera.PlayerOwner.Rotation.Pitch;
      Also I changed something within the custom control class:
      Code:
      simulated singular function Rotator GetBaseAimRotation()
      {
         local rotator   POVRot;
      
            POVRot = Controller.Rotation;
      
            return POVRot;
      }
      It used to say
      Code:
      POVRot = Controller.Pawn.Rotation;
      originally which was quite confusing for me since it is the pawn who calls the function in the first place. Maybe it made sense for a TopDown camera or maybe I missed the big picture...

      Comment


      • #4
        Hey Invor do you have a third person cam up and working with the camera module approach now?

        Comment


        • #5
          I'll just bump this...

          Comment

          Working...
          X