Weird offset/lag in only one axis when using scencecapture2d to make a portal effect

I originally posted this in the answerhub, but I may have more luck here.

I used the process outlined here to make a portal material, and then in C++ I made a class that holds a capture camera and a scenecapture2d component and has a target. This then finds the relative position and rotation offset between the object being rendered to and the player camera, and sets the capture camera’s relative offset from the target to be the same.

This method seems to work perfectly, as long as I am only translating my character, or yawing my view. When pitching my view up and down, the rendered view seems to get dragged up and down a bit, and have a jitter/rebound effect. Since it’s only in the pitch direction, it makes me think it has something to do with the camera rotation, rather than the rotation for the whole character. It’s hard to describe in a way that makes sense, so here’s a video of what I’m talking about.

For context, this is built off of the FPS C++ new project template, and the three arrows you can see are locked to the orientation and position of the camera. Sorry for the ****** quality, I hope it’s still visible that when moving in x,y,z, or rotating about yaw, the tracking on the portal is perfect, but as soon as I pitch up or down the tracking starts messing up. As far as I can tell, the tracking between the player camera and character camera is identical, and the FOVs are the same for both cameras.

The object that does the camera tracking has its tick group set to TG_PostPhysics. I tried messing around with the character’s tick group but it didn’t really seem to do anything. Here’s the code for the tracking:

    void ATP_Viewer::Tick( float DeltaTime )
    	Super::Tick( DeltaTime );
    	if (Player && Target)
    		UCameraComponent* PlayerCam = Player->GetFirstPersonCameraComponent();
    		FVector PlayerCamPos = PlayerCam->GetComponentLocation();
    		FRotator PlayerCamRot = PlayerCam->GetComponentRotation();
    		FVector TargetPos = Target->GetActorLocation();
    		FRotator TargetRot = Target->GetActorRotation();
    		FVector LocationOffset = PlayerCamPos - TargetPos;
    		FRotator RotationOffset = (PlayerCamRot.Quaternion()*TargetRot.Quaternion().Inverse()).Rotator();
    		CameraComp->SetRelativeLocation(LocationOffset, false);
    		CameraComp->SetRelativeRotation(RotationOffset, false);

Is there something I’m not considering, particularly in when and how the character camera’s rotation is done?

It was actually two problems hiding as one.

  1. The “dragging effect”, this was caused by the (I believe) pawn controller and something else fighting for control of the camera. To fix this, go to the character settings and check “Use pawn controller for pitch” (“use pawn controller for yaw” should already be checked, that’s why they were behaving differently!)

  2. The aspect ratio for my editor view was different than the aspect ratio for the camera I created (the aspect ratio of the two cameras was the same, it was specifically the editor window that was different) which caused a weird shift on the pitch because FOV is normalized by horizontal, not vertical FOV. When I launched the game and it went to its native resolution, the tracking was perfect.