Skip to main content
Version: 14 Oct 2024

XR Origin and ML Rig

This section provides information on how to create a Player Rig that is compatible with Magic Leap 2 and is driven by the user's head and controller movement controller. This can be done by either:

  1. Using Unity's Standard XR Origin (AR).
  2. Importing the ML Rig & OpenXR Input Sample and using the ML Rig.

Prerequisites

XR Origin (AR)

Developers can use the default Unity XR Origin. This section includes instructions on using the standard AR Origin to track the user's head pose and controller.

  1. Create the rig by selecting GameObject > XR > XR Origin (AR) from the main menu.
  1. Modify the camera offset values on the XR Origin component and/or the Camera Offset Transform’s Y value according to your application's needs. You can also set the origin's Tracking Origin Mode to modify your application's origin.

Magic Leap Rig & OpenXR Inputs Samples

The Magic Leap 2 Unity SDK still provides sample assets that a developer can use to quickly get started. To emphasize that these are merely examples rather than requirements, the following are now provided in the SDK package as a sample bundle named ML Rig & OpenXR Input:

  • ML Rig - A prefab containing an XR Origin with an offset of 0, with headpose tracking and a Controller object pre-configured to OpenXR action bindings. You can configure the XR Origin's Tracking Origin Mode to modify your application's origin.

  • MagicLeapOpenXRInput - An inputactions asset with Action Maps for HMD (head tracking), Controller, and Eyes. The device paths for Controller and Eyes require enabling the Magic Leap 2 Controller Interaction Profile and Eye Gaze Interaction Profile respectively.

Importing the Samples

  1. Opening Unity Package Manager
    1. Navigate to Window > Package Manager in Unity. This will open the Package Manager window.
  2. Selecting the Package
    1. In the Package Manager, select the Magic Leap SDK package from the list.
  3. Importing Samples
    1. In the package details, locate the Samples section which lists available samples.
    2. Click on the Import button next to the ML Rig & OpenXR Input sample.
  4. Confirming Import
    1. If prompted, confirm the import action by clicking Import.
    2. Unity will import the selected sample into your project. This may take a moment.
  5. Accessing Imported Samples
    1. Locate Magic Leap Rig and Input assets inside your project's /Assets/Samples/MagicLeapSDK/<Version>/ directory.
    2. Replace the Main Camera with the ML Rig from the samples folder.
The Magic Leap SDK Package with the "ML Rig & OpenXR Input" sample selected.

Input Handling

The Magic Leap 2 Unity SDK uses Unity’s Input System. The Input System is highly configurable and offers various ways to configure user input in your Unity project.

While earlier SDK versions included a MagicLeapOpenXRInput.inputactions asset, it's now considered deprecated for OpenXR development. It's recommended to set up input according to your project's specific needs.

Refer to input-specific guides in the OpenXR section of the Magic Leap 2 documentation for more information: