Skip to content

AR Interaction and placing objects

Yoan-Daniel Malinov edited this page Jun 12, 2024 · 2 revisions

First Example: Place Googley Eyes on an object to make it talk

For this, I am using the "FindTheStones_AR" blueprint - it basically is the same game as "FindTheStones", but with an added AR interaction as an example.

In this game, I want to visit the stones, but before I can talk to them, I have to place Googley Eyes on them in AR in order for them to come alive and tell me their story. This can be done with the XR features in the LUTE engine.

To start, we can go to the first stone, and add a "Toggle XR" order at the top, which then enables the camera and the AR tracking:

togglexr

It automatically fills in the plane and point cloud visualiser (this makes the planes/point clouds that the phone has detected visible), as well as the plane detection mode - if you only want vertical planes to be detected, you can select it there.

Once you have that, next thing to do is actually give it an order to place an object, coincidentally called "PlaceObjectOnPlane":

image

You have to give it a prefab to place (in this case it's the Googley Eyes), and a name which can be referenced in other orders. You can also specify if the object can only be places on Vertical or Horizontal planes. If you don't care about where it is placed, then you can select "Automatically Place Object", which, once a plane with the selected alignment is found, places the object on it. In our case, we want the user to place it themselves, so that is unticked, and we don't want the user to be able to rotate, scale, or move it after.

With this setup, once the user clicks on the plane and the object is placed, the next order is immediately executed - but if we want the user to interact with the object, for example click on the eyes, we can use the next order: "InteractWithXRObject".

image

You have to give the object name that you gave when placing the object, and without any other setting, this order will only execute and continue when you click on the object specified. You can add a custom InteractorEvent, or add anything else that can be called "On Interaction()", but that is for another tutorial.

And that's basically it, you toggled the XR camera, you placed an object on a detected plane, made the user click it, and now you can continue with the dialogue that the stone would say. Don't forget to toggle the XR off at the end, so that the user can continue looking at the map.

image

Second Example: Using the "XRDragInteraction" to add a drag interaction to the game.

If I wanted to make the game a bit more interactive in the AR mode, I could have it so when you go and put some "Googley Eyes" on the stones, you have to drag them to the correct position on the stone rather than just interact with them, and maybe scale them to fit it. To do this, there's the "XRDragInteraction" order:

image

The order itself has 4 main variables. The first is the object name that the order will use, which is the same as the name you gave in the place object order.

image