Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    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. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. 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:
    27
    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. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    212
    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. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    212
    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. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    212
    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:
    652
    Hi @timmunity

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

    tdmowrer

    Unity Technologies

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

    Griffo

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

    CarinaMclane

    Joined:
    Mar 12, 2014
    Posts:
    23
    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:
    736
    Griffo likes this.
  12. tehpro_unity

    tehpro_unity

    Joined:
    Oct 9, 2018
    Posts:
    1
  13. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    212