Search Unity

Question [OpenXR] How to check for position/rotation/velocity at time T instead of just "now" ?

Discussion in 'VR' started by SPollari, Dec 20, 2021.

  1. SPollari

    SPollari

    Joined:
    Sep 8, 2021
    Posts:
    6
    I've been learning the OpenXR API in Unity and I can't figure this out.

    Khronos documentation on OpenXR states that you can ask the runtime for Pose data with a timestamp.

    https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#xrLocateSpace

    Is this feature available in Unity?

    In Unity you can query the controllers for their position, rotation, velocity etc. during runtime, but can you specify at what time you wish to look at?
     
  2. colinleet

    colinleet

    Joined:
    Nov 20, 2019
    Posts:
    189
    XR positions are updated every frame. Unity uses the XR position update like a VSYNC, and delays running the next frame till it's ready with new data. This guarantees you to have a fresh location every frame.

    If you want a previous location for controllers/headset -- you would have to manually record those previous transform position/rotation. The best data structure to use would be a circular buffer the length of the number of frames you want to keep around, as it's non-ram-allocating after initiation: https://en.wikipedia.org/wiki/Circular_buffer
     
    Last edited: Aug 4, 2023
  3. Develle

    Develle

    Joined:
    Jan 18, 2023
    Posts:
    4
    I am facing the same problem. Did you find a solution? I asked a similar question here.