- Home /
Oculus Rift S camera offset at start,Oculus rift s offset camera at start
Hello, I have a problem on my Oculus Rift S on which I work. I'm using an XR Rig in my scene but when I click on play the camera of my XR Rig is shifted on the X and Z axis so I'm not centered properly and to fix this I have to go in the pause menu of Oculus and reset the view manually. I would like a method to reset the view directly in the code at start or understand where this offset comes from.
Answer by rh_galaxy · Oct 13, 2021 at 02:13 PM
I use this for Rift and Rift S in a sitting/standing game, but for Quest it has no effect (because you are supposed to recenter by holding down a menu button I think).
using UnityEngine.XR;
using UnityEngine.InputSystem;
float fRecenterTimer = 0.0f;
bool bTrackingOriginSet = false;
void Update()
{
//recenter logic
UnityEngine.XR.InputDevice headDevice = InputDevices.GetDeviceAtXRNode(XRNode.Head);
if (!bTrackingOriginSet) //always do once
{
if(headDevice!=null && headDevice.isValid)
{
headDevice.subsystem.TrySetTrackingOriginMode(TrackingOriginModeFlags.Device);
bTrackingOriginSet = true;
}
}
if (Menu.bRecenter) //replace with your own bool
{
fRecenterTimer += Time.unscaledDeltaTime;
if (fRecenterTimer > 3.0f)
{
if(headDevice!=null && headDevice.isValid)
{
headDevice.subsystem.TrySetTrackingOriginMode(TrackingOriginModeFlags.Device);
headDevice.subsystem.TryRecenter();
}
Menu.bRecenter = false;
fRecenterTimer = 0.0f;
}
}
}
Answer by Etaple · Oct 14, 2021 at 07:25 AM
@rh_galaxy Thank you very much for your help but unfortunately it does not work for me I always have this offset on the camera compared to the position of the XRrig.
Your answer
Follow this Question
Related Questions
How to fix Camera "corner cut" artefact 0 Answers
VR mirror view custom size and FoV 0 Answers
GearVR rotation stutter InputTracking.GetNodeStates 1 Answer
VR app controls are inverted 0 Answers
Float seems to be set to 0 at runtime Oculus Quest 0 Answers