cancel
Showing results for 
Search instead for 
Did you mean: 

how to reset the view?

Gerald
Expert Protege
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?
20 REPLIES 20

petergiokaris
Protege
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

Gerald
Expert Protege
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 🙂

Gerald
Expert Protege
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. 😉

petergiokaris
Protege
Awesome, I'm glad that it worked out for you Gerald!

davidhensley
Honored Guest
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?

Gerald
Expert Protege
You should have one place where you have all your keyboard inputs .... and there it is in the update loop.

bwiklund
Honored Guest
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?

AdamsImmersive
Honored Guest
"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.

Anonymous
Not applicable
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.