Search Unity

AR Planes "staying put" in-app

Discussion in 'AR' started by kizu7su, Jul 8, 2019.

  1. kizu7su

    kizu7su

    Joined:
    May 6, 2016
    Posts:
    5
    Hello,

    I've been tinkering with AR Foundation and ARCore, but I'm new to the Android scene. I followed Dan Miller's guide mentioned on this page: https://unity3d.com/how-to/create-AR-games-in-Unity-efficiently and main parts of my code are below. I had to change the code a little, since I'm using 2019.3.0a8. The main differences are that the raycasting isn't on the ARSessionOrigin, I had to put the new ARRaycastManager component on the ARSessionOrigin.

    I've been able to move the simple .apk and install it on a OnePlus 6T (heck of a time getting camera permissions), and now that I see the Plane starting to track on horizontal surfaces, it doesn't really stay "in the world" - it's always at the bottom of the vertical phone screen, and it stays at the bottom, relative to the phone. It will also start redrawing a new Plane on top of the existing Plane, still at the bottom of the screen. This just seems like a problem with the tools, not the simple code. I didn't think it would be the .0a8 version, but maybe that's it?

    I've uploaded a screenshot showing the planes on the bottom of the phone screen, and here's the code:

    Code (CSharp):
    1.     void Start() {
    2.         sessionOrigin = GetComponent<ARSessionOrigin>();
    3.         placeOnPlaneRaycastManager = GetComponent<ARRaycastManager>();
    4.     }
    5.  
    6.     void Update() {
    7.      
    8.         if (Input.touchCount > 0) {
    9.             Touch touch = Input.GetTouch(0);
    10.  
    11.             if (touch.phase == TouchPhase.Began) {
    12.                 if (placeOnPlaneRaycastManager.Raycast(touch.position, hits, TrackableType.PlaneWithinPolygon)) {
    13.                     Pose pose = hits[0].pose;
    14.                     Instantiate(PrefabToPlace, pose.position, pose.rotation);
    15.                 }
    16.             }
    17.         }
    18.     }
     

    Attached Files:

  2. aStrangeLoop

    aStrangeLoop

    Joined:
    Feb 17, 2018
    Posts:
    8
    Last edited: Jul 8, 2019
  3. kizu7su

    kizu7su

    Joined:
    May 6, 2016
    Posts:
    5
    Thank you for the info! I hope that doesn't get in the way of going landscape too, though.

    EDIT: I just set the Orientation to Portrait in the Player Settings but nothing changed with the Plane staying put. /EDIT

    I skimmed issue 96 but I'll look more later.

    Odd note about that: in order to fix my camera permission issue, I added the default "requesting permission" code for microphone access from the Unity documentation (https://docs.unity3d.com/Manual/android-RequestingPermissions.html). Without having to modify it at all to actually ask for camera rights, testing it with microphone references somehow forced the app to ask for camera permissions with the usual Android popup. If that info looks useful to the issue crew I'll share that. I spent the better part of last weekend getting around it, rofl.
     
    Last edited: Jul 8, 2019
  4. kizu7su

    kizu7su

    Joined:
    May 6, 2016
    Posts:
    5
    I reviewed that link further - I'm not using App Bundles, and the fix was applied in the 2019.3.0a8 version per tdmowrer's last post 18 days ago... shoot.

    I'm going to try the same simple scene on a few different builds after they finish installing, but other than that, I'm not quite sure what to try next.
     
  5. kizu7su

    kizu7su

    Joined:
    May 6, 2016
    Posts:
    5
    I have planes tracking on OnePlus 6T with Unity 2019.1.5F1, with the ARFoundation plugin 2.2.0 and ARCore XR plugin 2.1.0.

    So far, out of Unity builds 2019.3.0a8 and 2019.3.14f1, this is the only time where the planes are staying on the floor. It also auto-asked for the camera permissions, which did not happen in the other two builds.

    HTH someone down the road!
    kizu