Search Unity

  1. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Calculate distance for auto scaling.

Discussion in 'AR' started by StefanAugmentors, Oct 26, 2018.

  1. StefanAugmentors

    StefanAugmentors

    Joined:
    Nov 3, 2017
    Posts:
    15
    So I logged the distance returned by ARRaycastHit and the results are never as expected. Placing on a table close to the phone returns large values while placing on the ground further away returns smaller values. The results are also very inconsistent.

    I would like to get the distance to auto scale the AR scene. Anyone had any luck calculating the distance from the phone to the detected plane?
     
  2. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Hi,
    How are you calculating the distance? Could you be using the wrong coord space in your calcs? Ie. Session space vs world space?
     
  3. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    190
    Vector3.Distance between camera and ARRaycastHit position.
     
  4. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    577
    ARRaycastHit has a distance property. Does that give you the same value?
     
unityunity