Disable automatic head tracking for HTC Vive

I’m trying to disable the automatic head tracking for the HTC Vive (with the idea of enabling it later again but in a slightly different manner. So I can’t just disable HMD head tracking altogether).

My main candidate for disabling head tracking was to set LockToHmd to false in the camera of my player pawn. However, this doesn’t seem to have any effect. With LockToHmd disabled, the camera is still positioned and orientated based on the pose of the HMD.

To find out why LockToHmd does not work, and where the actual transformation takes place that locates the player camera, I looked through the UE code for references to GEngine->HMDDevice. Unfortunately that did not teach me anything, The code that uses LockToHmd often does not even get called in my test case and other places in the code only seem to set a rotation (while for me the HMD also positions the camera).

My theory now is that in ULocalPlayer::GetProjectionData the projection matrix is directly created based on the position and orientation of the HMD (without any obvious way of disabling this).

However, before I dig further into this and waste a lot of time on something that is potentially simply to do, I would like to ask if someone already did this and can provide some more insight into accomplishing this.

Hello. Any ideas about this sitaution?
I am try to lock camera position and set borders to camera rotation, but cant disable default hmd…
Player driver car… But can simple stand and get out from car chassis… Its ridiculous.
I am try to disable camera movement… but have no idea how to do it…

Thank you very much for your response! Good idea with inverse transform. Thanks!

I spent more time since my question to figure out the VR subsystem of UE and I have come to the conclusion it is pretty much impossible (without hacking the Engine source code) to prevent the Vive from using the tracking results. UE will always, without a way of turning it off, use the tracking data to setup the projection matrix for the camera.

The LockToHmd option in fact does the reverse from what I expected it to do initially. It lock the position and orientation of the CameraComponent to the position and orientation of the Vive instead of vice versa.

The only way I can think of to prevent the camera from using the Vive tracking results is to add a parent component that performs a reverse tracking transformation. This would effectively stop the camera from updating. Not elegant and probably not entirely perfect (late update might cause some problems), but it might be good enough.

Did adding the parents and applying the inverse transform work? Otherwise, I have to ask where you found the engine code that sets the projection matrix from the HMD.

I was looking to use the headset just for tracking purposes, but not for moving the camera in game. This solution may work for you as well.

UHeadMountedDisplayFunctionLibrary::EnableHMD(true);
UHeadMountedDisplayFunctionLibrary::GetOrientationAndPosition(_hmdRotation, _hmdPosition);
UHeadMountedDisplayFunctionLibrary::EnableHMD(false);

I’ve found that this solution causes a memory leak in 4.17.2. So don’t call this in Tick().