docs.unity3d.com
    Show / Hide Table of Contents

    Class XRRig

    The XR Rig component is typically attached to the base object of the XR Rig, and stores the that will be manipulated via locomotion. It is also used for offsetting the camera.

    Inheritance
    Object
    XRRig
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    public class XRRig : MonoBehaviour

    Properties

    cameraFloorOffsetObject

    The to move to desired height off the floor (defaults to this object if none provided). This is used to transform the XR device from camera space to rig space.

    Declaration
    public GameObject cameraFloorOffsetObject { get; set; }
    Property Value
    Type Description
    GameObject

    cameraGameObject

    The that contains the camera, this is usually the "Head" of XR rigs.

    Declaration
    public GameObject cameraGameObject { get; set; }
    Property Value
    Type Description
    GameObject

    cameraInRigSpaceHeight

    (Read Only) The camera's height relative to the rig.

    Declaration
    public float cameraInRigSpaceHeight { get; }
    Property Value
    Type Description
    Single

    cameraInRigSpacePos

    (Read Only) The camera's local position in rig space.

    Declaration
    public Vector3 cameraInRigSpacePos { get; }
    Property Value
    Type Description
    Vector3

    cameraYOffset

    Camera height to be used when in Device Tracking Origin Mode to define the height of the user from the floor. This is the amount that the camera is offset from the floor when moving the cameraFloorOffsetObject.

    Declaration
    public float cameraYOffset { get; set; }
    Property Value
    Type Description
    Single

    currentTrackingOriginMode

    (Read Only) The Tracking Origin Mode that this Rig is in.

    Declaration
    public TrackingOriginModeFlags currentTrackingOriginMode { get; }
    Property Value
    Type Description
    TrackingOriginModeFlags
    See Also
    requestedTrackingOriginMode

    requestedTrackingOriginMode

    The type of tracking origin to use for this Rig. Tracking origins identify where (0, 0, 0) is in the world of tracking. Not all devices support all tracking origin modes.

    Declaration
    public XRRig.TrackingOriginMode requestedTrackingOriginMode { get; set; }
    Property Value
    Type Description
    XRRig.TrackingOriginMode
    See Also
    XRRig.TrackingOriginMode

    rig

    The "Rig" is used to refer to the base of the XR Rig, by default it is this . This is the that will be manipulated via locomotion.

    Declaration
    public GameObject rig { get; set; }
    Property Value
    Type Description
    GameObject

    rigInCameraSpacePos

    (Read Only) The rig's local position in camera space.

    Declaration
    public Vector3 rigInCameraSpacePos { get; }
    Property Value
    Type Description
    Vector3

    trackingOriginMode

    The type of tracking origin to use for this Rig. Tracking origins identify where (0, 0, 0) is in the world of tracking. Not all devices support all tracking spaces.

    Declaration
    public TrackingOriginModeFlags trackingOriginMode { get; set; }
    Property Value
    Type Description
    TrackingOriginModeFlags

    trackingSpace

    Whether the experience is Room Scale or Stationary. Not all devices support all tracking spaces; if the selected tracking space is not set it will fall back to Stationary.

    Declaration
    public TrackingSpaceType trackingSpace { get; set; }
    Property Value
    Type Description
    TrackingSpaceType

    Methods

    Awake()

    See .

    Declaration
    protected void Awake()

    MatchRigUp(Vector3)

    This function will rotate the rig object such that the rig's up vector will match the provided vector.

    Declaration
    public bool MatchRigUp(Vector3 destinationUp)
    Parameters
    Type Name Description
    Vector3 destinationUp

    the vector to which the rig object's up vector will be matched.

    Returns
    Type Description
    Boolean

    Returns true if the rotation is performed or the vectors have already been matched. Otherwise, returns false.

    MatchRigUpCameraForward(Vector3, Vector3)

    This function will rotate the rig object around the camera object using the destinationUp vector such that:

    Declaration
    public bool MatchRigUpCameraForward(Vector3 destinationUp, Vector3 destinationForward)
    Parameters
    Type Name Description
    Vector3 destinationUp

    The up vector that the rig's up vector will be matched to.

    Vector3 destinationForward

    The forward vector that will be matched to the projection of the camera's forward vector on the plane with the normal destinationUp.

    Returns
    Type Description
    Boolean

    Returns true if the rotation is performed. Otherwise, returns false.

    MatchRigUpRigForward(Vector3, Vector3)

    This function will rotate the rig object around the camera object using the destinationUp vector such that:

    Declaration
    public bool MatchRigUpRigForward(Vector3 destinationUp, Vector3 destinationForward)
    Parameters
    Type Name Description
    Vector3 destinationUp

    The up vector that the rig's up vector will be matched to.

    Vector3 destinationForward

    The forward vector that will be matched to the forward vector of the rig object, which is the direction the player moves in Unity when walking forward in the physical world.

    Returns
    Type Description
    Boolean

    Returns true if the rotation is performed. Otherwise, returns false.

    MoveCameraToWorldLocation(Vector3)

    This function moves the camera to the world location provided by desiredWorldLocation. It does this by moving the rig object so that the camera's world location matches the desiredWorldLocation

    Declaration
    public bool MoveCameraToWorldLocation(Vector3 desiredWorldLocation)
    Parameters
    Type Name Description
    Vector3 desiredWorldLocation

    the position in world space that the camera should be moved to

    Returns
    Type Description
    Boolean

    Returns true if the move is performed. Otherwise, returns false.

    OnDestroy()

    See .

    Declaration
    protected void OnDestroy()

    OnDrawGizmos()

    Called when gizmos are drawn.

    Declaration
    protected virtual void OnDrawGizmos()

    OnValidate()

    See .

    Declaration
    protected void OnValidate()

    RotateAroundCameraPosition(Vector3, Single)

    Rotates the rig object around the camera object's position in world space using the provided vector as the rotation axis. The rig object is rotated by the amount of degrees provided in angleDegrees.

    Declaration
    public bool RotateAroundCameraPosition(Vector3 vector, float angleDegrees)
    Parameters
    Type Name Description
    Vector3 vector

    The axis of the rotation.

    Single angleDegrees

    The amount of rotation in degrees.

    Returns
    Type Description
    Boolean

    Returns true if the rotation is performed. Otherwise, returns false.

    RotateAroundCameraUsingRigUp(Single)

    Rotates the rig object around the camera object by the provided angleDegrees. This rotation only occurs around the rig's Up vector

    Declaration
    public bool RotateAroundCameraUsingRigUp(float angleDegrees)
    Parameters
    Type Name Description
    Single angleDegrees

    The amount of rotation in degrees.

    Returns
    Type Description
    Boolean

    Returns true if the rotation is performed. Otherwise, returns false.

    Start()

    See .

    Declaration
    protected void Start()
    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on Wednesday, October 27, 2021