I’m currently testing some things with the Oculus DK2 and UE4 4.7.5.
I’m trying to implement a simple view from a cockpit of a spacecraft. While the user camera is fixed to the cockpit, the cockpit itself need to be able to turn over three axis. The issue I’m encountering seems simple but I can’t figure out how to solve it.
My issue is : when rotating the cockpit I can end up upside down. Meaning my head is down and my legs are up. In this situation I get an offset different for each eye and my vision is not synced anymore. From what I understand the HMD stays in World Space and therefore compute a wrong eye position (basically they are inverted).
This is easily visible with this image :
You can see that when I’m head down (the gray ground is on top of the image) the cockpit is offset away from the center of the screen on the left eye (while the inverse happens on the right eye).
My current code is very simple and I’m not sure what do to fix that. My camera is a camera component attached to my Character class. I retrieve the HMD rotation to rotate it in relative space. This allow me to get relative rotation what orientation the cockpit has.
//----------------------------------------------------------------
//Update rotation
//----------------------------------------------------------------
//Retrieve HMD rotation/position
FQuat HmdCurrentOrientation;
FVector HmdCurrentPosition;
GEngine->HMDDevice->GetCurrentOrientationAndPosition(HmdCurrentOrientation, HmdCurrentPosition);
Camera->SetRelativeRotation( FRotator( HmdCurrentOrientation ) );
A solution I saw was to set the World to Meters scale in the World properties of my scene to 1 instead of 100. Unfortunately while it fix the rotation issue (because the offset between the eyes almost doesn’t change I believe), it makes my cockpit (and world) way too big.
Is there a way to handle the HMD in local space instead of world space ?