Use the MixedRealityPlayspace class from MRTK for Unity and set the Target Scale to either Room or Standing:
MRTK should handle the position of the playspace and camera automatically, but it’s good to double check:
Set your tracking origin mode on the XRInputSubsystem. After obtaining the subsystem, call TrySetTrackingOriginMode:
xrInputSubsystem.TrySetTrackingOriginMode(TrackingOriginModeFlags.Floor);
And work with Unity’s XRRig.
Since the Main Camera object is automatically tagged as the camera, Unity powers all movement and translation.
[!NOTE] These settings need to be applied to the Camera in each scene of your app.
By default, when you create a new scene in Unity, it will contain a Main Camera GameObject in the Hierarchy which includes the Camera component, but does not have the settings below properly applied.
Namespace: UnityEngine.XR
Type: XRDevice
For a standing-scale or room-scale experience, you’ll need to place content relative to the floor. You reason about the user’s floor using the spatial stage, which represents the user’s defined floor-level origin and optional room boundary, set up during first run.
To ensure that Unity is operating with its world coordinate system at floor-level, you can set and test that Unity is using the RoomScale tracking space type:
if (XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale))
{
// RoomScale mode was set successfully. App can now assume that y=0 in Unity world coordinate represents the floor.
}
else
{
// RoomScale mode was not set successfully. App cannot make assumptions about where the floor plane is.
}
Once your app successfully sets the RoomScale tracking space type, content placed on the y=0 plane will appear on the floor. The origin at 0, 0, 0 will be the specific place on the floor where the user stood during room setup, with -Z representing the forward direction they were facing during setup.