Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.07k stars 1.15k forks source link

Image Tracking Position Relative to Ar Session Origin #480

Closed saitakturk closed 4 years ago

saitakturk commented 4 years ago

Hi, I would like to get tracked image position and rotation for re-positioning of arsession origin. However, tracked image position and rotation is relative to ar camera according to my experiments. I could not find whether tracked image space-dependent ar camera or ar session origin. Can you please elaborate more?

tdmowrer commented 4 years ago

All trackables (an ARTrackedImage is a "trackable") are parented to the session origin. This means an ARTrackedImage's transform's localPosition and localRotation are relative to the session origin, while its position and rotation are in Unity world space (this is how all Transform components work).

The hierarchy looks something like

- ARSessionOrigin
    - ARCamera*
    - Trackables
        - ARTrackedImage1
        - ARTrackedImage2
        - ...

* Note the ARCamera is usually under the session origin, but it doesn't have to be. Things probably won't line up correct if it isn't, though.

saitakturk commented 4 years ago

Thank you localPosition and localRotation is working.