Setting HMD Location

Hi, I’m just starting out with VR development. I’ve been able to make some basic levels but I’m struggling to get the VR Preview to consistently start in the same orientation.

I’m using the MotionControllerPawn in 4.13. When I put the Pawn in the level I have set it to face in a particular direction and I have set the location to be at floor level, at the origin. When I put the HMD on it isn’t looking in the same direction as the Pawn. I thought this might be because I wasn’t using the StartPlayerPawn so I added one and that means I now get a consistent starting view but that is dependent on the mouse position not the headset.

Does anyone know how I can make the orientation consistent? I want to to be able to put on the headset in a particular orientation in the physical world and for that consistently match the orientation in VR.

Yeah, this was a tricky problem for me too.

The problem is that your final camera orientation is going to be a combination of the character orientation and HMD orientation. If the player start position starts with a yaw of 90 degrees, but the HMD starts at 0 degrees, the final yaw rotation will be 90 degrees. If you start both the player start and HMD at 0 degrees, and then slide the mouse to rotate the controlled character, the final rotation will be a combination of the HMD yaw and character yaw. This is actually a good thing though. If the player is playing a seated FPS game and their head is always facing straight forward and they’re using the mouse to change their characters orientation, that’s totally great. The character head will always face forward. If the player turns their head, it should change the orientation of the characters head, but not their body. This lets players look over their shoulder while still running forward.

Do you have any suggestions for setting the 0,0,0 point? I would like toework with my vive on a seated game (sitting in a cockpit), but my problem is that my chair isn’t in the middle of my play space. So when I spawn the pawn in the cockpit and put the hmd on, my head location is outside the aircraft. How should I be structuring the positions of the cockpit in the world, the pawn in the cockpit and the hmd in the pawn so this works?

Yeah, I solved this problem last week and I’ve got it working perfectly now. Here’s a link to my previous forum post which sort of alludes to how I did it:

On the architecture side, I have a pawn which contains all of the HMD interfaces. The pawn is the “head” of a character which gets mounted onto the body of a full body avatar. All of the VR interfaces are done in the head, and I can drop it on top of any body I want to control with VR controllers. As long as the body implements the VR interface, it can be controlled by the head pawn. The advantage here is that I can directly read and write the head position in world space, regardless of where the head is in room scale space. So, if the player starts the game at the edge of their play space and their head spawns in an unplayable area, no problem! I am always setting the head to the controlled character head mount position, so the player head is instantly mounted to the correct position.

Room scale movement get’s a little bit more tricky. You can’t let the HMD move on its own with the player movement (so disable “Lock to HMD”). Instead, you want to capture the position delta of the HMD (each frame) and then apply that delta as a movement input for the character. The beautiful bonus of this approach is that your controlled character drives the HMD movement, and your HMD movement also drives the character, so if the player tries to walk through a wall, the capsule collider will prevent that from happening. You can also measure the change in player height and apply a change to the capsule half height to reflect the change in height profile, which then allows players to crouch and walk under overhanging obstacles. The other advantage here is that because the head is disembodied, you can have a VR spectator and set it’s position at any time! The final bonus with this approach is that you can build out all of your VR hardware interfaces in the VR Head pawn, and then those interactions can passed on to whatever character you’re controlling. So, if you have 20 characters in your game, the you only have to implement the VR hardware interface once, and if you have 2+ VR hardware platforms you’re supporting, you add the support into the VR head pawn and all 20 of your characters will automatically work with it. In software engineering terms, this would be called a “layer of abstraction”. If I wanted to add PSVR support or Leap Motion support, it would be relatively trivial and painless.

Last night I got this interface working perfectly for room scale VR with both the Oculus Rift + Touch and HTC Vive. I can switch out the VR hardware without changing a thing, and I get the exact same game play experience. This uniform platform consistency is fantastic to design against :smiley: