Skip to main content
Up and Coming
May 20, 2013

how to reset the view?

When the game starts the Rift is assuming the current position is the start position.

I would like to be able to override that in case you started at a bad position. But I am not sure what to call to do that. How can I reset the view?
    This topic has been closed for replies.

    20 replies

    Inspiring
    May 20, 2013
    Hi Gerald,

    There is a function in CameraController called SetOrientationOffset.

    If you have not attached the camera to follow another objects Transform via the member FollowOrientation, upon the OVRCameraController construction, the OrientationOffset of the camera will be set according to the initial orientation of the camera. So, you can manually set this offset orientation via the above function to whatever orientation you please.

    You might even consider actually resetting the tracker as well, via OVRDevice.ResetOrientation(0) (which will set the tracker to the identity quaternion orientation) and see if this gives you the granularity you are looking for to really force the camera into the direction you desire.

    Best,
    Peter
    Peter Giokaris Senior Software Engineer
    GeraldAuthor
    Up and Coming
    May 20, 2013
    Hi Peter,

    sounds about like just what I was looking for. Thank you, that is awesome.

    I don't follow another objects Transform, but have the Oculus Cam riding piggyback on my original cam. That way all the things I do to my original cam also affect the Oculus Cam. Works pretty well and makes integration into my games (which are not first person) really easy.

    I will try that now :)
    check out my Mobile VR Jam 2015 title Guns N' Dragons
    GeraldAuthor
    Up and Coming
    May 20, 2013
    perfect - works as I want it.

    my game normally works with a camera looking into a fixed direction, so the drift was an issue as well as a starting position that did not work. this is now a simple and easy to do fix, many Leap Motion games will have the same issue.

    now I can always reset it it by pressing a key.

    if (Input.GetKeyDown("left ctrl"))
    {
    OVRDevice.ResetOrientation(0);
    }

    Thanks again Peter. I will look into how to integrate the new yaw correction at a later point. I am aware this is not the optimal solution. ;)
    check out my Mobile VR Jam 2015 title Guns N' Dragons
    Inspiring
    May 21, 2013
    Awesome, I'm glad that it worked out for you Gerald!
    Peter Giokaris Senior Software Engineer
    New Participant
    August 5, 2013
    if (Input.GetKeyDown("left ctrl"))
    {
    OVRDevice.ResetOrientation(0);
    }


    Hi guys,
    thanks for this thread it has been helpful. Where did you put the reset line of code? I'm kind of a beginner at coding so its not obvious to me. I tried adding it in the SetOrientationOffset function. Does that sound right?
    GeraldAuthor
    Up and Coming
    August 5, 2013
    You should have one place where you have all your keyboard inputs .... and there it is in the update loop.
    check out my Mobile VR Jam 2015 title Guns N' Dragons
    Up and Coming
    October 26, 2013
    I get this error:

    Assets/Dolly.js(32,17): BCE0005: Unknown identifier: 'OVRDevice'.


    What's the right way to get the reference to OVRDevice inside a script?
    Up and Coming
    November 23, 2013
    "bwiklund" wrote:
    I get this error:

    Assets/Dolly.js(32,17): BCE0005: Unknown identifier: 'OVRDevice'.


    What's the right way to get the reference to OVRDevice inside a script?


    Same error and question here. I'm sure I'm looking right at the answer and not seeing it!

    Thanks.
    — Morgan — Mac OS X ❆ Unity
    November 23, 2013
    I didn't look at the Unity package yet, but assuming that the function called ResetOrientation() is in a script called OVRDevice, wich is attached to a gameobject called "OVRController" or something like this, you should reference it in the dolly.cs script in the awake() function, for example :


    private OVRDevice ovrdevice ; // This is the variable you'll use to reference the OVRDevice script.
    void Awake()
    {
    ovrdevice = GameObject.Find(OVRController).GetComponent<OVRDevice>() ; // Here, we reference the script OVRDevice, attached to the gameobject OVRController, in our variable ovrdevice.
    }
    void Update()
    {
    if (Input.GetKeyDown("left ctrl")) // If the player press left ctrl (listed as an imput in Unity in the inputs window)...
    {
    ovrdevice.ResetOrientation(0); // ... we call the ResetOrientation() function of the OVRDevice script referenced in our ovrdevice variable.
    }
    }


    Colours would have helped here, sorry about that.
    Up and Coming
    November 23, 2013
    Thanks! I was almost there but not quite...

    (And I'll post a JS version for posterity as soon as I try that out.)
    — Morgan — Mac OS X ❆ Unity