Project 3: Barrel Bouncer AR Edition

Part 3: Enabling Plane Detection and Visualization

Go to your AR Session Origin GameObject and add the AR Plane Manager component to it. You will notice that it has two properties that you can set: Plane Prefab and Detection Mode. The former is the reference to the prefab that the plane manager should use to visualize the planes it detects. The latter defines what types of planes (i.e. horizontal, vertical) the plane manager should be tracking.

Let’s create the plane prefab. On your menu bar, go to GameObject -> XR -> AR Default Plane. This will create a new gameobject that defines the plane’s visualization to look like this:

Image showing AR Foundation's default plane visualization

However, we want the planes in our game to look a little nicer, perhaps something like this dotted pattern:

Image showing feathered plane as visualization

Unity calls this a “feathered plane”, because the material fades out towards the edges of the plane. According to this link, the term feathering refers to:

This feathered plane shown in the screenshot above uses a material that is included in the AR Foundation samples, but isn’t part of AR Foundation itself. We have provided it for you as part of our unitypackage.

On your AR Default Plane GameObject, find its Mesh Renderer component and drag the FeatheredPlaneMaterial (which can be found in the Materials folder in your project window) into its Materials property. Next, remove the Line Renderer component from the GameObject (since the default visualization draws a black line around the planes’ boundaries, but we don’t want that in ours) and add the AR Feathered Plane Mesh Visualizer script to it (this helps ensure that the feathering effect only occurs towards the planes’ boundaries).

Once you have done these steps, drag the GameObject into the project window to make a prefab out of it, and then delete the instance from your scene. You may rename the prefab for clarity, if you would like. Finally, set it as the Plane Prefab that should be used for visualizations by dragging it into the appropriate slot on the AR Plane Manager.

Bonus Task (Optional)

Previous Section | Go Home | Next Section