Use an AR camera in conjunction with a 3D object to interact with the object in a real-world setting.
Add an AR Camera
An AR camera is required to interact with a 3D object in a real-world setting.
An AR camera is composed of a Camera object with a Device Tracker component.
Add a Camera component by going to the Hierarchy panel and clicking the Add button [+] > Scene Object > Camera.
Then select the Camera object in the Hierarchy panel and in the Inspector panel, click + Add component > AR Capability > Device Tracker.
There you have an AR camera!
By default, a Camera object is available in the Hierarchy panel when you create a project. If you do not need the default camera, you can delete it by right-clicking it and selecting Delete.
Configure the Device Tracker of an AR Camera
The Device Tracker component obtains the rotation and position of your device. Device Tracker can be used to create experiences in an AR environment. For example, you can place a 3D object or character on the ground or have drones fly in the air.
Device Tracker Properties
- World: Supports 6 degrees of freedom in space, which captures the position and orientation of the device in the real-world space. Use this mode when you want to position the object at a specific location in the world.
- Orientation: Support 3 degrees of freedom in space, which detects only the orientation, and not position, of the device in the real-world space.
To configure the Device Tracker for AR, Select the Camera object in the Hierarchy panel and locate the Device Tracker component in the Inspector panel.
From the Tracking Mode dropdown, choose World. This ensures that all objects rendered by the AR camera are tracked in the world setting. You can now hold your device and move around freely.
An object keeps the same relative position as the camera, so you should avoid walking too close to, or too far from, the placed object.
Place a 3D Object in the Real World
Let’s try to create an effect where UFOs float in the air!
Import 3D Assets
Start by downloading the following assets and importing them into Effect House:
Add Imported Assets to the Scene
Drag the imported UFO model to the Hierarchy panel.
Set the Transform of the Object
Starting in Effect House v2.1.0, the default measurement of scale changed from meters to centimeters. This unit change better aligns the scale in the 3D scene with the scale in the preview. Previously, a 3D object was scaled down by 100x. Now you can easily adjust the object’s position and rotation to your liking!
Set the scale of the UFO to match the real-world unit. Create an empty scene object by clicking the Add button [+] > Empty Mesh in the Hierarchy panel.
You can rename the empty scene object by right-clicking the Empty Mesh object and selecting Rename. Enter a new name, for instance, Ar container.
Select the empty scene object in the Hierarchy panel and locate its Transform component in the Inspector panel. Change the X, Y, and Z values of Scale to 0.05, 0.05, and 0.05, respectively.
Then drag the UFO model below the empty scene object and select the UFO model. Locate its Transform component in the Inspector panel, and change the X, Y, and Z values of Scale to 1, 1, and 1, respectively.
Preview an AR Effect
To better preview an AR effect, click the Preview in TikTok button, and scan the QR code to test your effect.