Setting world origin when setting floor height

Hi,

We're making an app for the Magic Leap 2 (as well as for other devices like Quest). When starting the app, the world origin is set to the camera position, as I understand is the expected behaviour of ARFoundation. We then want to place an object on the floor in front of the user, and this requires us to do some processing to find where the floor actually is.

When we've reached this point, we can instantiate new objects with this floor offset value, great. However the issue is that we're loading in additional scenes after device startup, and now each of these load with 0,0,0 at eye height, unless we manually offset the content in this scene when it is loaded.

My question is, is there a way to set the world origin in ARFoundation, so that content is loaded correctly from the start? When I find the floor height, can I tell Unity to use this new position as world origin?

Yes, it is possible to move the world origin in AR Foundation. The ideal mechanic would be tapping on a detected plane and the world origin moves to that tapped position. This is similar to the SetWorldOrigin method that is included in ARKit

However, this functionality is not directly exposed in AR Foundation. A similar effect can be achieved by changing the transform of the AR Session Origin so that the Camera appears to be in a different part of your virtual world.

You might also want to look into the MakeContentAppearAt method, which was designed to achieve something similar to what you describe.

For more detailed information on how to use AR Session and AR Session Origin to place and manipulate objects in AR, you can refer to this Unity tutorial

Best,

El