Skip to main content
Up and Coming
February 27, 2015

"Press 'R' to reset orientation" implementation in Unity

Sorry to be such a total noob. I know there have been other posts about this and I have read through them:
viewtopic.php?t=1162
viewtopic.php?f=37&t=20535

I created a script in Unity called RecenterView.js:
#pragma strict

function Start () {

}

function Update () {
if (Input.GetKeyDown("left ctrl"))
{
OVRManager.display.RecenterPose();
}
}


When I return to Unity from MonoDevelop, I have a red ! error message saying:
Assets/Scripts/RecenterView.js(10,25): BCE0005: Unknown identifier: 'OVRManager'.

Once I actually get this script to not have syntax errors, to what element of my project hierarchy will I attach this script?

Without this script, my project compiles fine and displays properly in my DK2.

Thank you kindly for your help.
    This topic has been closed for replies.

    2 replies

    Up and Coming
    February 28, 2015
    Hi BluePotato,

    I'm not a C# developer, but maybe it is because you're not defining a public class?

    Below are the two we use. The first is if we want to call in a reset automatically:

    using UnityEngine;
    public class ResetCamera : MonoBehaviour {
    void OnEnable() {
    OVRManager.display.RecenterPose();
    }
    }


    The next is if we want to call in a reset on user interaction:

    using UnityEngine;

    public class ResetCameraAnyKey : MonoBehaviour {
    // Update is called once per frame
    void Update () {
    if (Input.anyKeyDown)
    OVRManager.display.RecenterPose();
    }
    }


    Hope this helps!
    Cubicle Ninjas Custom VR App Development Guided Meditation VR for Rift, Gear, and Go
    Up and Coming
    March 2, 2015
    Thank you! Success!