Skip to main content
Up and Coming
February 9, 2014

Forcing a predefined OVRPlayerController view/rotation

Hello guys,

I am building a script in which I am changing the location of the user (like predefined points of view in the scene).
No problem to set the position of the OVRPlayerController, but I am struggling with the rotation...

What I want to achieve is really to force the user to a specific camera view, so that after updating the position/location, the camera is turned toward a specific item.
I tried setting the OVRPlayController roration properties, but that does not work, as it is still reflecting the current Rift rotation.
I tried also setting the OVRCameraController rotation, but that does not work. I finally tried using the setYRotation function, no luck either...

Could you advice on how to update the OVRPlayerController rotation so that the user is facing the specific direction (probably ressting the current rotation values)

Thank you
    This topic has been closed for replies.

    12 replies

    Up and Coming
    February 9, 2014
    You just shouldn't do that.

    HMD angle is a camera offset from your actual angle.
    Up and Coming
    February 10, 2014
    I think this worked for me with a similiar scenario:

    float direction = -120f;
    // reset overplayer rotation
    ovrplayer.transform.rotation = Quaternion.identity;
    // set current forward rotation
    ovrplayer.SetRotation(direction);


    HTH,

    Peter
    Check out my Unity VR development blog: http://talesfromtherift.com @peterept
    Up and Coming
    February 10, 2014
    raidho36, could you explain what not do that ?
    I am well aware of the VR guidlines for proper experience, but here I want to have the user enter a scene by a nice fadein at some specific location with some specific camera direction...

    Any idea how ?
    Setting both the OVR player controller direction and the OVR cameracontroller direction (like setting the torso direction and eyes/neck direction)

    Thanks
    Up and Coming
    February 10, 2014
    You didn't read the spoiler did you.

    It said that the HMD angle is an offset off desired angle.
    Inspiring
    February 11, 2014
    While it's possible to do this with some hacking, it is not recommended. If you rotate the camera by script, or lock the rotation, it will be a bad user experience. The better thing is to leave the control to the player and use contextual cues to guide them to look where you want. For example, you can have someone talking, or an explosion sound that will tell them where to look.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    February 11, 2014
    What I don't understand is that it is possible to define the position and orientation of the OVRPlayerController in Unity so that when you start you game, it is placed and facing the direction you set.
    Why could that not easily done during the game ?
    Let's say for example that the user dies and need to restart the entire level at the starting point... how would you do that then ?

    Of course I want to keep a good VR experience for the player. In this case, in some particular situation, the screen fades to black for 2 seconds and during that complete fade out, I want to move and playerController and set a new orientation, so that when fade in is done, the user is where I need to and looking in the requested direction...

    What I don't get is why just rotating the main OVRPlayerController object does not rotate the camera view, as it is a child object of that one...
    Inspiring
    February 11, 2014
    I'm no Unity expert but this should be easy enough. I'll take a look when I get home if nobody has already answered you.
    Up and Coming
    February 12, 2014
    If you call Start() on the OVRPlayerController after setting the rotation, that should do the trick I believe.
    Inspiring
    February 12, 2014
    "boone188" wrote:
    If you call Start() on the OVRPlayerController after setting the rotation, that should do the trick I believe.


    That does the trick indeed.

    Actually, what you need to do is set the OrientationOffset of the camera (which raidho36 hinted at) to your new rotation and also reset YRotation which is exactly what InitializeInputs() does. (Called from Start()).

    Example:


    GameObject Teleporter = GameObject.FindGameObjectWithTag("Teleporter");
    transform.position = Teleporter.transform.position;
    transform.rotation = Teleporter.transform.rotation;
    OrientationOffset = transform.rotation;
    YRotation = 0.0f;
    Up and Coming
    February 18, 2014
    thanks for this trick. I'll try that out and let you know !