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

**URL:** <https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612>\
**Category:** XR Development\
**Tags:** htc, lag, Vive, UE4-21, unreal-engine, hmd, question\
**Created:** [August 14, 2018, 9:42am UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612 "2018-08-14T09:42:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_de7966ea](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_de7966ea](https://forums.unrealengine.com/u/anonymous_user_de7966ea)\
**Post date:** [August 14, 2018, 9:42am UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612/1 "2018-08-14T09:42:22Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Hustlan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hustlan](https://forums.unrealengine.com/u/Hustlan)\
**Post date:** [August 24, 2018, 9:40am UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612/2 "2018-08-24T09:40:59Z")

</div>

I have the same problem

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_98092ca1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_98092ca1](https://forums.unrealengine.com/u/anonymous_user_98092ca1)\
**Post date:** [August 30, 2018, 8:19am UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612/3 "2018-08-30T08:19:10Z")

</div>

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;
	}
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_98092ca1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_98092ca1](https://forums.unrealengine.com/u/anonymous_user_98092ca1)\
**Post date:** [September 3, 2018, 10:56am UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612/4 "2018-09-03T10:56:14Z")

</div>

And don’t forget to mark this as answered 🙂

---

<div class="post-metadata">

**Author:** ![MasterOfShapes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MasterOfShapes](https://forums.unrealengine.com/u/MasterOfShapes)\
**Post date:** [October 11, 2018, 4:29am UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612/5 "2018-10-11T04:29:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_98092ca1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_98092ca1](https://forums.unrealengine.com/u/anonymous_user_98092ca1)\
**Post date:** [October 15, 2018, 3:07pm UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612/6 "2018-10-15T15:07:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![iNSCAPE85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iNSCAPE85](https://forums.unrealengine.com/u/iNSCAPE85)\
**Post date:** [July 5, 2019, 7:43am UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612/7 "2019-07-05T07:43:29Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![iNSCAPE85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iNSCAPE85](https://forums.unrealengine.com/u/iNSCAPE85)\
**Post date:** [January 16, 2020, 7:41pm UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612/8 "2020-01-16T19:41:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![peterfrance](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@peterfrance](https://forums.unrealengine.com/u/peterfrance)\
**Post date:** [March 28, 2024, 1:24am UTC](https://forums.unrealengine.com/t/vive-hmd-lag-when-lock-to-hmd-is-set-to-off-in-4-20/431612/9 "2024-03-28T01:24:40Z")

</div>

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