Search code examples
unity-game-engineaugmented-realityarcore

Can I run ARCore Preview 1 App on Preview 2 release?


I've built an app which runs on ARCOre preview 1 package on Unity. I know Google has made major changes in preview 2. My question is what changes will I have to make in order to run my ARCore preview 1 app run on preview 2?


Solution

  • Take a look at the code in the Preview 2 sample app(s) and update your code accordingly. For example, here is the new code for properly instantiating an object into the AR scene:

    if (Session.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
                {
                    var andyObject = Instantiate(AndyAndroidPrefab, hit.Pose.position,
                        hit.Pose.rotation);
    
                    // Create an anchor to allow ARCore to track the hitpoint 
                    // as understanding of the physical world evolves.
                    var anchor = hit.Trackable.CreateAnchor(hit.Pose);
    
                    // Andy should look at the camera but still be flush with the plane.
                    andyObject.transform.LookAt(FirstPersonCamera.transform);
                    andyObject.transform.rotation = Quaternion.Euler(0.0f,
                        andyObject.transform.rotation.eulerAngles.y,
                           andyObject.transform.rotation.z);
    
                    // Make Andy model a child of the anchor.
                    andyObject.transform.parent = anchor.transform;
                 }