Road to FullbodyIK suited for VR

I started this project to deepen my knowledge around the Oculus Rift and the Unreal Engine. As I want to move the character with the thumbstick combined with the ability to move around in the real world / roomscale, there weren’t any tutorials that suits my needs. My inspiration is basically the game “Onward“.

Most of the tutorials and forum threads are either about teleporting or the thumbstick part but not a combination of them with roomscale movement. The trickiest part was taking the player’s character with him while moving in real world.

As I didn’t succeed to locate any helpful advice, it was up to me to experiment a lot. My experience is topic of this post.

Initial Setup
The player’s avatar blueprint bases on ACharacter. And has the following components:

Basically, my solution involves the following steps:

1. Disabling the “Lock to Hmd” option of the Camera
2. And use the HMD position information to move the whole actor instead of just the camera (actual HMD position minus the HMD position of the last frame equals the vector that has to be applied to the actor/scene root)
3. Apply the same math but reversed to the motion controllers
4. Apply the HMD rotation to the camera directly, but add the actor rotation on top of it

Click to enlarge the image

Apply the HMD position data to the scene root (2)
Each frame (or tick) the system will add the HMD position vector (device position) relative to its origin in real world to the world location of the scene root, the capsule component. Than it will store this correction vector into a variable for usage in the next frame.
This time, the stored vector will be subtracted from the device position to only calculate the delta that the player created while moving in that single frame. That delta (device position – HMDLocationLastFrame) is than added to the capsule component, looped each frame.

Motion Controller correction (3)
The last intervention gives birth to another problem. As the scene root changes so the motion controllers do. That means: the calculated delta is also applied to the motion controller locations. The solution is to reverse the math done above: 

Click to enlarge

Two little corrections are included, also. First, the capsules height has to be added and second, there is some displacement between my real hands and their representation in game on the x axis. The correction shown in the picture will not be final. It is still not that precise that I like it to be.

Apply HMD rotation to the camera
The only thing that is left is implementing the HMD rotation. As the scene root is going to rotate, its rotation value needs to be added to the device rotation. But only the yaw, cause the rest will may be part of the animation blueprint.

Click to enlarge

Conclusion
The results are promising and very close to what I have in my mind. Still, there are some issues:

  • The motion controllers aren’t exactly at the location of my hands in real world. To make it even worth, the offset is depending on the direction I am looking at.
  • As the capsule component does handle the collision, it is not possible to “just” crouch in the real world and expecting something similar in the game.
  • Also, the capsule component prevents the player to move into walls or other obstacles. Primarily, that is a good thing, but the way it forces the player back causes a little bit nausea at the moment.

I will have to investigate a little bit more…