AR Planes "staying put" in-app

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:

    void Start() {
        sessionOrigin = GetComponent<ARSessionOrigin>();
        placeOnPlaneRaycastManager = GetComponent<ARRaycastManager>();
    }

    void Update() {
      
        if (Input.touchCount > 0) {
            Touch touch = Input.GetTouch(0);

            if (touch.phase == TouchPhase.Began) {
                if (placeOnPlaneRaycastManager.Raycast(touch.position, hits, TrackableType.PlaneWithinPolygon)) {
                    Pose pose = hits[0].pose;
                    Instantiate(PrefabToPlace, pose.position, pose.rotation);
                }
            }
        }
    }

I was having the same problem and I resolved it by setting orientation to portrait in the player settings.

However, I’m still experiencing this issue when I export my AR project as a library ( Integration Unity as a library in native Android app ) in the latest alpha.

EDIT:
I think it has to do with this issue (ARCore fails when building google play app bundle · Issue #96 · Unity-Technologies/arfoundation-samples · GitHub)

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 (Unity - Manual: Request runtime permissions). 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.

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.

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