Magic Leap 2 usage with External Positioning System

Hello everyone,

I’m currently working on a project that uses an absolute coordinate positioning system. We receive data indicating the desired position and orientation of a Rover in global space, and we convert this information into a local Unity position and rotation.

My question is:
What is the proper way to handle this in Unity such that Magic Leap’s internal positioning system does not affect the Camera’s pose?

Specifically, I would like to:

  • Prevent the Unity camera from being automatically updated when the Magic Leap device is physically moved.
  • Allow runtime toggling between the Magic Leap 2’s internal positioning and a custom absolute positioning system.

How can this be implemented in a clean, non-hacky way, without resorting to techniques like inverting the Magic Leap tracking data and adding offsets from the custom system?

Hey @P.Gagelas,

Welcome to the Magic Leap Developer Forums!

To achieve what you’re looking for you can try toggling the TrackedPoseDriver that is located on the Main Camera of the ML Rig (or possibly whatever XR rig you are currently using).

I tried it out myself and had success.
I made a script that toggle the TrackedPoseDriver on and off when I pressed the trigger on the MLController.

When the component was toggled off, I then moved the camera on the Y axis by 1m.

Then I toggled the TrackedPoseDriver back on and the device returned to it’s expected position in space and continued tracking normally.

Here’s a snippet of the code I used to test it out

if (!headsetPoseDriver.enabled)
{
    Vector3 camLocalPos = mainCam.transform.localPosition;
    mainCam.transform.SetLocalPositionAndRotation(new Vector3(camLocalPos.x, camLocalPos.y + 1, camLocalPos.z), Quaternion.identity);
    Debug.Log($"{mainCam.transform.localPosition.x}, {mainCam.transform.localPosition.y}, {mainCam.transform.localPosition.z}");
}

Let me know if you test it out and it works for you!

Best,
Corey