Tap to Place in the World | AR Unity Developer

Derek Anderson
2 min readApr 11, 2024

--

Previously, I covered the AR Raycast Manager, which will handle the AR raycasts that will be used in the AR app. One of the pieces that will be used is the AR Placement Interactable, which will allow a user to tap the screen to place an object on a plane. Let’s see how this is done.

Start by adding an AR Placement Interactable in the Hierarchy View, which will also add an XR Interaction Manager if one hasn’t been added yet. The Ar Placement Interactable has a script component where the XR Origin can be dragged over and slotted in. Like some of the VR Interactables, there are Interaction Events that the AR Placement Interactable can utilize.

With the AR Placement Interactable in the project, it’s time to create a placement prefab. A simple cube will do the trick. Create the cube and change the scale of the cube. A smaller one will be preferred since I will be seeing it on my desk or other flat areas of the room I’m developing in. Scale to your desire and drag it into the prefabs folder. Drag it to the AR Placement Interactable spot for Placement Prefab and delete the cube from the scene once done.

A component that is needed for the AR Placement Interactable to place the cube with the AR raycast is the AR Gesture Interactor. This component goes on the Main Camera, not the XR Origin. Link up the XR Origin and the XR Interaction Manager on the interactor.

Unfortunately, I can’t test this out in a simulated environment because it’s still a work in progress, but I can build and run this on my Android device to see if it works, and it does!

--

--