Weird offset/lag in only one axis when rendering from SceneCapture2D

anonymous_user_ce443be0
Sat, 17 Oct 2015 02:07:38 +0000
Rendering

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?

3 posts - 2 participants