Each time i restart unity play mode the XR Rig tracking origin mode “floor” doesn’t align with the floor i had set up in oculus, it just goes to the height of the headset. It is fixed if i turn the Tracking origin mode to “device” and then back to “floor”, but doing this everytime i start play mode is frustrating. Does anyone know how to fix this?
Hi, did you find a solution for this? For me it seems to happen in Editor only if I put on the headset via Quest Link after the app has started already.
I have worked on a workaround that solves this issue for now for me:
using System.Collections;
using System.Collections.Generic;
using Unity.XR.CoreUtils;
using UnityEngine;
using UnityEngine.XR;
/// <summary>
/// Workaround for this issue https://discussions.unity.com/t/xr-rig-tracking-origin-mode-floor-doesnt-align-after-restart/336353
/// This issue seemed to happen only when putting the headset after the Editor started to play
/// </summary>
public class XROriginFloorFix : MonoBehaviour
{
[SerializeField] private XROrigin xrOrigin;
private bool isInitialized;
private void Update()
{
if (IsHardwarePresent() && !isInitialized)
{
StartCoroutine(InitializeCoroutine());
isInitialized = true;
}
}
public static bool IsHardwarePresent()
{
var xrDisplaySubsystems = new List<XRDisplaySubsystem>();
SubsystemManager.GetInstances<XRDisplaySubsystem>(xrDisplaySubsystems);
foreach (var xrDisplay in xrDisplaySubsystems)
{
if (xrDisplay.running)
{
return true;
}
}
return false;
}
private IEnumerator InitializeCoroutine()
{
xrOrigin.RequestedTrackingOriginMode = XROrigin.TrackingOriginMode.Device;
yield return new WaitForSeconds(0.1f);
xrOrigin.RequestedTrackingOriginMode = XROrigin.TrackingOriginMode.Floor;
}
}
I managed to get this fixed after deleting the XR Origin and adding it back again. (Rule 0: Turn it off then turn it back on again.)