Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Setting world scale without affecting physics

Discussion in 'ARCore' started by kexar66, Oct 11, 2017.

  1. kexar66

    kexar66

    Joined:
    Feb 27, 2013
    Posts:
    24
    Hi,
    I want to be able to scale up / down the scale of AR scene. How can I setup the scale for a whole AR scene without affecting physics? When I set scale of root GameObject it breaks physics (wheel colliders).

    Thanks
     
  2. timmunity

    timmunity

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    78
    Great question! I just gave a talk about this last week at Unite Austin. The talk and sample code will be posted next week, but the short answer is: do not scale your content (because physics will be affected, for example); instead scale all positional information coming from the device. This includes the position of the camera, the plane positions, boundaries, and extents. The easiest way to do this is to put the camera and all GameObjects generated by the device (e.g. TrackedPlanes) under the same parent GameObject, and apply scale to that. So your hierarchy might be

    AR Root
    Camera [Components: TrackedPoseDriver, SessionComponent]
    AR Controller [Components: HelloARController]
    If you then scale the "AR Root" GameObject, then it should scale the camera and visual representation of the planes. Note, however, that it hit tests within ARCore won't be aware of the scale, so you'll need to remove the scale from your raycast input and then rescale the result.

    Hope that makes sense! Let me know if you have any questions.

    Cheers,
    Tim
     
    CarinaMclane and HenryAsh like this.
  3. mattrified_

    mattrified_

    Joined:
    Jul 17, 2013
    Posts:
    29
    Quick follow-up question. Does the local positions / rotations of the Camera and ARController matter before trying this scaling method? Do they need to be at [0,0,0] and identity?
     
  4. timmunity

    timmunity

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    78
    For the camera, that depends on whether you check the "Use relative transform" checkbox on the TrackedPoseDriver. If it is checked, then it remembers the initial position+rotation ("pose") and makes the final pose relative to that initial pose.

    For the ARController, the HelloARController spawns in plane prefabs using itself as the parent, so its position+rotation would also matter.
     
  5. timmunity

    timmunity

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    78
    Let me just clarify: the initial position+rotation matters because it affects things in the way I mentioned above, but scale should still work (fingers crossed; I haven't tried this specific setup).
     
  6. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    648
    Hi @timmunity

    You said 'The talk and sample code will be posted next week' have you a link to this please, thanks.
     
  7. timmunity

    timmunity

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    78
    Arkade and Griffo like this.
  8. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    648
  9. CarinaMclane

    CarinaMclane

    Joined:
    Mar 12, 2014
    Posts:
    21
    Ha, thanks for this. Got myself in a right pickle scaling content and (attempting to) correct for physics with our first play with ARCore a few months back.
     
  10. kbabilinski

    kbabilinski

    Joined:
    Jul 12, 2012
    Posts:
    13
  11. jimmya

    jimmya

    Unity Technologies

    Joined:
    Nov 15, 2016
    Posts:
    674
    Griffo likes this.