Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

ARFoundation - rotate/scale

Discussion in 'AR' started by Tarrag, Aug 4, 2018.

  1. Tarrag


    Nov 7, 2016
    Hi all,

    I've been pulling hairs to get the object to rotate or scale correctly so I'm coming to the well hoping for some help :)

    I am using the ARFoundation scene, Unity 2018.2.1f1, "com.unity.xr.arfoundation": "1.0.0-preview.16". Trigger scale/rotation by onValueChanged.AddListener delegates for the sliders:

    The cube is instantiated at root in the hierarchy. I tried to hold the cube in place both with if (Physics.Raycast(ray, out hit, 100f, m_layerMask)) and if (m_ARSessionOrigin.Raycast(ray, s_Hits, TrackableType.PlaneWithinPolygon)) but it doesn't make a difference.

    ARSessionOrigin m_ARSessionOrigin=GameObject.FindWithTag("ARSessionOrigin").GetComponent();
    m_ARSessionOrigin.transform.rotation = Quaternion.AngleAxis(rotationSlider.value, Vector3.up); //to rotate
    m_ARSessionOrigin.transform.localScale =*scaleSlider.value; // to scale

    When scaling I can see on console the scale slider value change, the localScale transform of ARSessionOrigin change, and the object (cube) in the scene transform.position/localScale does not change as expected. However the cube shoots off as if transposed. The equivalent happens with rotation.

    Here's a short video with the cube's behaviour

    The left slider is scaling and the right slider is rotation in the vid.

    Keeping the above setup but childing the cube to trackablesParent when instantiated, the cube rotates correctly but nothing happens when I scale ARSessionOrigin. I have not read in the forum the intantiated object should be childed to trackablesParent though, so not sure this is the intended hierarchy.

    Can someone please shed some light what I'm doing wrong to scale/rotate?

    Thanks a bunch for your help!
    Last edited: Aug 5, 2018
  2. tdmowrer


    Unity Technologies

    Apr 21, 2017
    Hi Sergio,

    I've seen a lot of questions on this, so I created a new forum post here:

    Let me know if that clears it up for you.