UNITY | AR DEVELOPMENT | XR INTERACTION TOOLKIT | XR ORIGIN | AR SESSION

AR Basics with XR Interaction

Import the XR Interaction Package and set up the Basic Components

Jordan T Kay
2 min readJun 24, 2024

--

STEPS NEEDED

  1. Import XR Interaction Toolkit
  2. Create & Configure an XR Origin (AR) GameObject
  3. Create & Configure an AR Session GameObject

STEP ONE — Import XR Interaction Toolkit

Window > Package Manager > XR Interaction Toolkit

STEP TWO — Create & Configure an XR Origin (AR) GameObject

Scene > Create > XR > XR Origin (AR)

The XR Origin GameObject configures multiple GameObjects and components that work together to convert data from XR Tracking Systems into real-world positions.

XR Origin contains a Main Camera GameObject which stores not only components to make the camera function, but also 3 components to allow it to function within AR.

  1. AR CAMERA MANAGER → The control center for the android device’s camera. Enabling/disabling the component also enables/disables the device’s camera. The component also provides a way for scripts to interact with and control camera-related functions.
  2. AR CAMERA BACKGROUND → Displays live video from the device’s camera as the backdrop in the scene. Enabling this component shows the AR background, while disabling this component will hide the background video.
  3. TRACKED POSE DRIVER → Uses the current position and orientation data from the device to update the position and orientation of the Main Camera’s Transform.

XR Origin also contains two child GameObjects to reference a Left Controller and Right Controller. As this is going to be a mobile application, the need for a left and right controller is not required. But, if the application does warrant a headset release in the future, it is easy to implement the controls we use for mobile to controls needed for remotes.

STEP THREE — Create & Configure an AR Session

Scene > Create > XR > AR Session

The AR Session is what controls the lifecycle and configuration options for an AR Session. Enabling the ARSession starts the session while disabling the ARSession ends the session, clearing any ongoing AR experiences. There can only be 1 ARSession in a given scene at a time, otherwise multiple sessions will want control and errors will occur.

--

--

Jordan T Kay

Join my journey into game development with Unity. Learning all I can to produce quality games. 🚀