0

I'm trying to edit the default oculus camera scripts to stop responding to the tracking sensor for a period of time and then resume normal movement from the place where the camera pointed at the time it stopped following the tracking sensor.

I was able to stop the camera from responding to the tracking sensor, but now when it resumes working it "snaps" to the position where the camera would be if the sensor was not deactivated. I, however, want it to just "seamlessly" resume tracking. So I guess I also have to stop some variable from updating during that time.

Here is my code so far, it's situated in the OVRCamera script in the function SetCameraOrientation:

if (Time.realtimeSinceStartup >= 11f && Time.realtimeSinceStartup <= 17f)
{
    camera.transform.rotation = lastRotation;
}
else
{
    camera.transform.rotation = q;
    lastRotation = q;
}

And this is the variable declaration for my new variable:

private Quaternion          lastRotation        = new Quaternion();

I'd appreciate it if someone could help me out.

Thanks.

Timguin
  • 23
  • 1
  • 3
  • What are your trying to achieve? If you freeze the tracking data then restore it, the user may be looking upwards and now they would be looking else where? Or do you want to freeze only around the y-axis? – peterept Oct 12 '14 at 22:43
  • One thing to bear in mind is that freezing/resuming head tracking greatly increases the likelihood of causing motion sickness. Check out the best practices document for more information: http://static.oculus.com/sdk-downloads/documents/Oculus_Best_Practices_Guide.pdf – Adam McKee Nov 11 '14 at 22:10

1 Answers1

0

If you want to resume tracking from where you left off, then when you resume, you need to record the delta between the current orientation and lastRotation so that you can apply the delta inverse from then on...

I don't know the exact syntax for the Unity quaternions, but you want something like this:

if (Time.realtimeSinceStartup >= 11f && Time.realtimeSinceStartup <= 17f)
{
    camera.transform.rotation = lastRotation;
    deltaRotation = q * lastRotation.inverse();
}
else
{
    lastRotation = q * deltaRotation.inverse();
    camera.transform.rotation = lastRotation;
}
Jherico
  • 28,584
  • 8
  • 61
  • 87
  • I see what you mean and your code looks very promising. I will try it out later and report back, but thank you already. – Timguin May 22 '14 at 12:59