Class XRRig | XR Interaction Toolkit | 0.10.0-preview.7
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 GameObject that will be manipulated via locomotion. It is also used for offsetting the camera.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    XRRig
    Inherited Members
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(String, Single)
    MonoBehaviour.InvokeRepeating(String, Single, Single)
    MonoBehaviour.CancelInvoke(String)
    MonoBehaviour.IsInvoking(String)
    MonoBehaviour.StartCoroutine(String)
    MonoBehaviour.StartCoroutine(String, Object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(String)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(Object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, Component)
    Component.TryGetComponent<T>(T)
    Component.GetComponent(String)
    Component.GetComponentInChildren(Type, Boolean)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(Boolean)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, Boolean)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(Boolean)
    Component.GetComponentsInChildren<T>(Boolean, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, Boolean)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(Boolean)
    Component.GetComponentsInParent<T>(Boolean, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(String)
    Component.SendMessageUpwards(String, Object, SendMessageOptions)
    Component.SendMessageUpwards(String, Object)
    Component.SendMessageUpwards(String)
    Component.SendMessageUpwards(String, SendMessageOptions)
    Component.SendMessage(String, Object)
    Component.SendMessage(String)
    Component.SendMessage(String, Object, SendMessageOptions)
    Component.SendMessage(String, SendMessageOptions)
    Component.BroadcastMessage(String, Object, SendMessageOptions)
    Component.BroadcastMessage(String, Object)
    Component.BroadcastMessage(String)
    Component.BroadcastMessage(String, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Component.rigidbody
    Component.rigidbody2D
    Component.camera
    Component.light
    Component.animation
    Component.constantForce
    Component.renderer
    Component.audio
    Component.networkView
    Component.collider
    Component.collider2D
    Component.hingeJoint
    Component.particleSystem
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    [AddComponentMenu("XR/XR Rig")]
    [DisallowMultipleComponent]
    public class XRRig : MonoBehaviour

    Properties

    cameraFloorOffsetObject

    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 GameObject 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

    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" GameObject is used to refer to the base of the XR Rig, by default it is this GameObject. This is the GameObject 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

    trackingSpace

    Whether 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

    Awake()

    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. Returns false otherwise.

    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. Returns false otherwise.

    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. Returns false otherwise.

    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. Returns false otherwise.

    OnDrawGizmos()

    Declaration
    protected virtual void OnDrawGizmos()

    OnValidate()

    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. Returns false otherwise.

    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. Returns false otherwise.

    Start()

    Declaration
    protected void Start()
    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