Search Unity

Resolved Portably retrieving reality up vector

Discussion in 'AR' started by JasonC_, Jun 2, 2021.

  1. JasonC_

    JasonC_

    Joined:
    Oct 27, 2019
    Posts:
    66
    Is there a portable way to retrieve [at least an estimate of] the real-world up or down vector (i.e. a direction parallel to gravity) when using the Unity XR plugin architecture?

    It's possible this is a silly question, but most of the apps I've written don't care about world space (mostly I work in some arbitrary headset relative space defined by video + external tracking input) so I never really looked into it before.
     
  2. FrankvHoof

    FrankvHoof

    Joined:
    Nov 3, 2014
    Posts:
    258
    ARFoundation is set up such that Vector3.up in worldspace corresponds with the real-world up-vector.

    Edit: Of course, it also assumes that the earth is a flat plane ;) So depending on how 'big' you application is, you might need to start looking at other ways to do this otherwise (e.g. by directly reading from the Accelerometer)
     
    JasonC_ likes this.
  3. JasonC_

    JasonC_

    Joined:
    Oct 27, 2019
    Posts:
    66
    Perfect, thank you!

    :D