How to debug.log the position of headset

I know tracked pose driver can get the position of the headset. Which is the way to debug.log the position variable? which variable should I debug.log?

Tracked Pose Driver’s transform

It is possible to get the position/orientation of the headset directly from the input system, if that’s what you’re interested in.

For instance, in our particle system code, we use something like this:

using UnityEngine;
using UnityEngine.InputSystem;

public class LogDevicePose : MonoBehaviour
{
    InputAction m_HeadPositionInputAction;
    InputAction m_HeadRotationInputAction;

    void Start()
    {
        m_HeadPositionInputAction = new InputAction();
        m_HeadPositionInputAction.AddBinding("<HandheldARInputDevice>/devicePosition");
        m_HeadPositionInputAction.Enable();

        m_HeadRotationInputAction = new InputAction();
        m_HeadRotationInputAction.AddBinding("<HandheldARInputDevice>/deviceRotation");
        m_HeadRotationInputAction.Enable();
    }

    void Update()
    {
        Debug.Log(m_HeadPositionInputAction.ReadValue<Vector3>());
        Debug.Log(m_HeadRotationInputAction.ReadValue<Quaternion>());
    }
}

Thanks for your reply. However, when I copy this script and put it under the XR origan. The debug.log shows that the position and rotation are always (0,0,0). I am now using polyspatial 2.0.0-pre11 Unity 6000.0.19f1

And you’re either using Metal mode or an Unbounded volume camera in RealityKit mode, and this is from a build on simulator or device? The head position isn’t available to Bounded (i.e., non-exclusive) apps. If you submit a repro case as a bug report and let us know the incident number (IN-#####), we can look at what might be going wrong.

It is unbound mode. I am now using play to device in real device (not simulator).

Play to Device doesn’t currently support transferring the head position; it will only work in actual builds. We expect to add support for transferring the device pose in our next release.

Thanks for your reply

And I really hope Object Tracking can be released in the later version. One stuff in Unity mentioned it 2 month ago. :grinning: