Search Unity

Question Scaling ARSessionOrigin and working with large objects in ARFoundaiton

Discussion in 'AR' started by TheLastDantes, May 21, 2021.

  1. TheLastDantes

    TheLastDantes

    Joined:
    Apr 17, 2021
    Posts:
    1
    Hello, I am new to ARFoundation, and I'm struggling to get the scaling for larger scenes to work. I know that in order to work with larger objects you should scale ARSessionOrigin, but when you do it? If I set the scale in the editor plane detection ceases to work, and if I try to do it after plane detection the placement doesn't seem to work.

    So as an example I have a cube with a scale transform (100,100,100) and I want it to be roughly 1 metre cubed on the plane. In my script to place the object:

    Code (CSharp):
    1. // If there's a touch
    2.         if (m_RaycastManager.Raycast(Input.GetTouch(0).position, m_Hits, TrackableType.PlaneWithinPolygon))
    3.         {
    4.             // Begin or move
    5.             if (Input.GetTouch(0).phase == TouchPhase.Began || Input.GetTouch(0).phase == TouchPhase.Moved)
    6.             {
    7.                 // Find the position
    8.                 // Move AR session to get content at ray position  
    9.                
    10.                 m_session.MakeContentAppearAt(placeableObject.transform, m_Hits[0].pose.position, m_Hits[0].pose.rotation);
    11.                 if (placeableObject.activeSelf == false)
    12.                 {
    13.                     m_session.transform.localScale = fixedScale;
    14.                 }
    15.                 // Set content to active
    16.                 placeableObject.SetActive(true);
    17.                 disablePlaneTracking();
    18.                 disableExistingPanes();
    19.             }
    20.  
    21.         }
    with a fixed scale being: fixedScale = Vector3.one * scaleFactor; (in this case 100?)

    So my question is when placing an object, do I do:
    1. m_session.transform.localScale = fixedScale; (Change ARSession scale)
    2. m_session.MakeContentAppearAt(placeableObject.transform, m_Hits[0].pose.position, m_Hits[0].pose.rotation);

    Or do I add the content, then apply the scale? Neither seems to work.

    Thanks.
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820