Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

ARFoundation - rotate/scale

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

  1. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    40
    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 = Vector3.one*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!
    Sergio
     
    Last edited: Aug 5, 2018
  2. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    269
    Hi Sergio,

    I've seen a lot of questions on this, so I created a new forum post here: https://forum.unity.com/threads/scaling-with-arfoundation.543953/

    Let me know if that clears it up for you.
     
    Tarrag likes this.