Proper way to rotate VR camera.

I’m having difficulty figuring out the proper way to rotate a VR camera.

Currently the position and the rotation of the headset is unreadable and sets based off of your hardwares tracking. The current well known work around for creating movement or rotation for the player is is to create a parent object and move or rotate that parent object instead of the camera. The problem with this is when rotating the parent the rotation is based off of the pivot of the parent object and not of the camera. This can create some terribly offset rotations for people using room scale tracking. What is the work around for this? I’m sure I’m not the only one who has ran into this problem.

1 Like

There is no workaround. It’s broken

Did you happen to find any solution here? I’ve reached this problem now and cannot think of a solution.

rotate the parent with an offset set to your cameras position.

1 Like

You can rotate the parent around the head’s position, that way you don’t rotate around the playspace center, but instead around the head center :slight_smile:

2 Likes
parentTransform.RotateAround(new Vector3(HeadTransform.position.x, 0, HeadTransform.position.z), Vector3.up, 45.0f);
7 Likes

For my game I have it as it’s been explained before:

Empty Parent GameObject

  • Main Camera
  • UI Camera

If I want to force the player to look in a particular direction, I simply edit the transform of the Empty Parent GameObject.

When I fade out, I use a fade sphere around the Empty Parent GameObject so that all of the cameras get enshrouded in darkness. When it’s faded out, I can then subtract the Main Camera rotation from the Empty Parent GameObject rotation…or…something I’d have to look at how I did that, but it certainly is possible to get the player to be forced to look in a particular direction.

I just checked since it’s been a while since implementing this and I’m using Steam Fade + rotate around.

Awesome, I didn’t realize that was possible!

I ended up raycasting where the camera was, rotating the parent of the camera, raycasting the new position of the camera, then moving the parent object the same as the difference between the raycast…

Needless to say, this is significantly simpler. Thanks!

1 Like

Not a worry at all :slight_smile:

1 Like

There is a movement option for this in the oculus sample framework. It’s also being used in Dash home too. The character controller can now follow the head when you walk, that way both objects rotate correctly. In oculus home, look down. That circle on the ground is your invisible character controller’s feet. Walk a few feet and watch it transition to your new location.

This is easy to mimic in unity by using the default character controller, and overriding the ‘center’ to equal your heads local X and Z position.

1 Like

You can take this further and set the height of the character controller to the distance between your head and the playspace, that way you have a character controller that follows your real position, and adjusts to your height in realtime :slight_smile:

How do you override the center? Doesn’t altering the center, just push your head out further? Could you explain how to do this? I don’t want to use all the extra stuff in the framework and would rather just adjust the standard ovrplayercontroller.

So I’m talking about unitys built-in CharacterController component, you simply need to set the center variable on the component to equal the local X and Z of the head. That way the controller will always be in line with your head, imitating the behavior seen in Oculus Home.

Thank you. I’ll give this a try. I like the input scripts on the OVR stuff and have exploited screen fades and things so I’ll need to walk back a lot of that or learn how to use the OVRPlayerController script on the unity char controller. Wish Oculus had just added the ability to walk and rotate from the start. Very confusing to beginners.

This is the solution. It’s hacky as hell but it’s the standard AFAIK. You have to create an artificial offset for the roomscale. Just subtract the difference between the camera position and the tracker center point. I got some code I can copy pasta if anyone needs it.

You have to do this every frame by the way…

use RotateAround(), it’s much less painful.