Skip to content

Latest commit

 

History

History
63 lines (43 loc) · 3.68 KB

vr-setup-standing-include.md

File metadata and controls

63 lines (43 loc) · 3.68 KB

Use the MixedRealityPlayspace class from MRTK for Unity and set the Target Scale to either Room or Standing:

MRTK settings window

MRTK should handle the position of the playspace and camera automatically, but it's good to double check:

MRTK playspace

  1. From the Hierarchy panel, expand the MixedRealityPlayspace GameObject and find the Main Camera child object
  2. In the Inspector panel, find the Transform component and change the Position to (X: 0, Y: 0, Z: 0)

Set your tracking origin mode on the XRInputSubsystem. After obtaining the subsystem, call TrySetTrackingOriginMode:

xrInputSubsystem.TrySetTrackingOriginMode(TrackingOriginModeFlags.Floor);

And work with Unity's XRRig.

XR rig in hierarchy

  1. Go to Other Settings section of the Windows Store Player Settings
  2. Choose Windows Mixed Reality as the device, which may be listed as Windows Holographic in older versions of Unity
  3. Select Virtual Reality Supported

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.
}
  • If SetTrackingSpaceType returns true, Unity has successfully switched its world coordinate system to track the stage frame of reference.
  • If SetTrackingSpaceType returns false, Unity was unable to switch to the stage frame of reference, likely because the user has not set up a floor in their environment. While a false return value isn't common, it can happen if the stage is set up in a different room and the device is moved to the current room without the user setting up a new stage.

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.