VIVE HMD Lag When 'Lock To HMD' is Set to Off in 4.20.

I upgraded to 4.20 and after a while of happily using it realized that the visuals in the HMD were lagging in a way that they never did in version 4.19. The lag goes away if I set the ‘lock to HMD’ variable to ‘on’, however I don’t want to do this because the game I’m building requires the HMD view to be set relative to the controller position (I’m building an actuated flight simulator and so can’t have the view of the HMD change as the actuators move, I get around this problem by having the view be set relative to a controller that is on the seat and so also moves with the actuators). I can’t go back to version 4.19 and every time I try some of my files stop working. Does anybody know where this lag is coming from?

Any help with this problem would be very much appreciated.
Thanks!

I have the same problem

I had the same problem, btw it’s not exclusive to VIVE, starting from 4.20 unticking bLockToHmd disables LateUpdate which introduces a noticeable lag. The best workaround over this is to create a new class that inherits ‘UCameraComponent’ and override ‘GetCameraView’ function with this code:

void UCameraComponent::GetCameraView(float DeltaTime, FMinimalViewInfo& DesiredView)
{
	if (GEngine && GEngine->XRSystem.IsValid() && GetWorld() && GetWorld()->WorldType != EWorldType::Editor )
	{
		IXRTrackingSystem* XRSystem = GEngine->XRSystem.Get();
		auto XRCamera = XRSystem->GetXRCamera();

		if (XRCamera.IsValid())
		{
			if (XRSystem->IsHeadTrackingAllowed())
			{
				const FTransform ParentWorld = CalcNewComponentToWorld(FTransform());

				if (bLockToHmd)
				{
					XRCamera->SetupLateUpdate(ParentWorld, this, false);

					FQuat Orientation;
					FVector Position;
					if (XRCamera->UpdatePlayerCamera(Orientation, Position))
					{
						SetRelativeTransform(FTransform(Orientation, Position));
					}
					else
					{
						ResetRelativeTransform();
					}
				}

				XRCamera->OverrideFOV(this->FieldOfView);
			}
		}
	}

	if (bUsePawnControlRotation)
	{
		const APawn* OwningPawn = Cast<APawn>(GetOwner());
		const AController* OwningController = OwningPawn ? OwningPawn->GetController() : nullptr;
		if (OwningController && OwningController->IsLocalPlayerController())
		{
			const FRotator PawnViewRotation = OwningPawn->GetViewRotation();
			if (!PawnViewRotation.Equals(GetComponentRotation()))
			{
				SetWorldRotation(PawnViewRotation);
			}
		}
	}

	if (bUseAdditiveOffset)
	{
		FTransform OffsetCamToBaseCam = AdditiveOffset;
		FTransform BaseCamToWorld = GetComponentToWorld();
		FTransform OffsetCamToWorld = OffsetCamToBaseCam * BaseCamToWorld;

		DesiredView.Location = OffsetCamToWorld.GetLocation();
		DesiredView.Rotation = OffsetCamToWorld.Rotator();
	}
	else
	{
		DesiredView.Location = GetComponentLocation();
		DesiredView.Rotation = GetComponentRotation();
	}

	DesiredView.FOV = bUseAdditiveOffset ? (FieldOfView + AdditiveFOVOffset) : FieldOfView;
	DesiredView.AspectRatio = AspectRatio;
	DesiredView.bConstrainAspectRatio = bConstrainAspectRatio;
	DesiredView.bUseFieldOfViewForLOD = bUseFieldOfViewForLOD;
	DesiredView.ProjectionMode = ProjectionMode;
	DesiredView.OrthoWidth = OrthoWidth;
	DesiredView.OrthoNearClipPlane = OrthoNearClipPlane;
	DesiredView.OrthoFarClipPlane = OrthoFarClipPlane;

	// See if the CameraActor wants to override the PostProcess settings used.
	DesiredView.PostProcessBlendWeight = PostProcessBlendWeight;
	if (PostProcessBlendWeight > 0.0f)
	{
		DesiredView.PostProcessSettings = PostProcessSettings;
	}
}

And don’t forget to mark this as answered :slight_smile:

Having the same issue but does the answer givin require the engine to be built from source?

No, you can simply create a child of UCameraComponent inside your project.

Same problem here… When in Blue print i check the look to HMD, it generates a not sustainable lag when you rotate the head… Basically it is a motion sickness generator.
Please fix this problem becuase it never occurred in 4.19 version or lower…

I have the same problem with 4.24. Is there a way to solve it with BP?

Ever figure this out? Can’t get it working.