Class XRRig | XR Interaction Toolkit | 0.0.6-preview
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, the game object 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

    Gets or sets the GameObject to move to desired height off the floor (defaults to this object if none provided).

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

    cameraGameObject

    The game object that contains the camera, this is usually the 'Head' of XR rigs.

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

    cameraInRigSpaceHeight

    Gets the camera's height relative to the rig.

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

    cameraInRigSpacePos

    Gets the camera's local position in rig space.

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

    cameraYOffset

    Gets or sets the amount the camera is offset from the floor (by moving the camera offset object).

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

    rig

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

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

    rigInCameraSpacePos

    Gets the rig's local position in camera space.

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

    trackingSpace

    Gets or sets if the experience is rooms 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

    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

    true if the rotation is performed or the vectors have already been matched.

    MatchRigUpCameraForward(Vector3, Vector3)

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

    • the camera will look at the area in the direction of the destinationForward
    • the projection of camera's forward vector on the plane with the normal destinationUp will be in the direction of destinationForward
    • the up vector of the rig object will match the provided destinationUp vector, note that the camera's Up vector can not be manipulated
    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

    true if the rotation is performed.

    MatchRigUpRigForward(Vector3, Vector3)

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

    • the forward vector of the rig object, which is the direction the player moves in Unity when walking forward in the physical world, will match the provided destinationUp vector
    • the up vector of the rig object will match the provided destinationUp vector
    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

    true if the rotation is performed.

    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

    true if the move is performed

    RotateAroundCameraPosition(Vector3, Single)

    Rotates the rig object around the camera objects 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

    true if the rotation is performed

    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

    true if the rotation is performed

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023