docs.unity3d.com
    Show / Hide Table of Contents

    Class XROrigin

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

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    XROrigin
    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: Unity.XR.CoreUtils
    Syntax
    [AddComponentMenu("XR/XR Origin")]
    [DisallowMultipleComponent]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.core-utils@2.0/api/Unity.XR.CoreUtils.XROrigin.html")]
    public class XROrigin : MonoBehaviour

    Properties

    Camera

    The Camera to associate with the XR device. It must be a child of this XROrigin.

    Declaration
    public Camera Camera { get; set; }
    Property Value
    Type Description
    Camera
    Remarks

    The Camera should update its position and rotation according to the XR device. This is typically accomplished by adding a TrackedPoseDriver component to the Camera.

    CameraFloorOffsetObject

    The GameObject 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 XR Origin space.

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

    CameraInOriginSpaceHeight

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

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

    CameraInOriginSpacePos

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

    Declaration
    public Vector3 CameraInOriginSpacePos { 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 of this XR Origin.

    Declaration
    public TrackingOriginModeFlags CurrentTrackingOriginMode { get; }
    Property Value
    Type Description
    TrackingOriginModeFlags
    See Also
    RequestedTrackingOriginMode

    Origin

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

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

    OriginInCameraSpacePos

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

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

    RequestedTrackingOriginMode

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

    Declaration
    public XROrigin.TrackingOriginMode RequestedTrackingOriginMode { get; set; }
    Property Value
    Type Description
    XROrigin.TrackingOriginMode
    See Also
    XROrigin.TrackingOriginMode

    TrackablesParent

    The parent Transform for all "trackables" (for example, planes and feature points).

    Declaration
    public Transform TrackablesParent { get; }
    Property Value
    Type Description
    Transform

    Methods

    Awake()

    See MonoBehaviour.

    Declaration
    protected void Awake()

    MatchOriginUp(Vector3)

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

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

    the vector to which the XR Origin 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.

    MatchOriginUpCameraForward(Vector3, Vector3)

    This function will rotate the XR Origin 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 XR Origin object will match the provided destinationUp vector (note that the camera's Up vector can not be manipulated)

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

    The up vector that the origin'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.

    MatchOriginUpOriginForward(Vector3, Vector3)

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

    • The forward vector of the XR Origin 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 XR Origin object will match the provided destinationUp vector

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

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

    Vector3 destinationForward

    The forward vector that will be matched to the forward vector of the XR Origin 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 XR Origin 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 MonoBehaviour.

    Declaration
    protected void OnDestroy()

    OnDisable()

    See MonoBehaviour.

    Declaration
    protected void OnDisable()

    OnEnable()

    See MonoBehaviour.

    Declaration
    protected void OnEnable()

    OnValidate()

    See MonoBehaviour.

    Declaration
    protected void OnValidate()

    RotateAroundCameraPosition(Vector3, Single)

    Rotates the XR origin object around the camera object's position in world space using the provided vector as the rotation axis. The XR Origin 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.

    RotateAroundCameraUsingOriginUp(Single)

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

    Declaration
    public bool RotateAroundCameraUsingOriginUp(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 MonoBehaviour.

    Declaration
    protected void Start()

    Events

    TrackablesParentTransformChanged

    Invoked during Application.onBeforeRender whenever the TrackablesParent transform changes.

    Declaration
    public event Action<ARTrackablesParentTransformChangedEventArgs> TrackablesParentTransformChanged
    Event Type
    Type Description
    Action<ARTrackablesParentTransformChangedEventArgs>

    Extension Methods

    MonoBehaviourExtensions.StartRunInEditMode(MonoBehaviour)
    MonoBehaviourExtensions.StopRunInEditMode(MonoBehaviour)
    In This Article
    • Properties
      • Camera
      • CameraFloorOffsetObject
      • CameraInOriginSpaceHeight
      • CameraInOriginSpacePos
      • CameraYOffset
      • CurrentTrackingOriginMode
      • Origin
      • OriginInCameraSpacePos
      • RequestedTrackingOriginMode
      • TrackablesParent
    • Methods
      • Awake()
      • MatchOriginUp(Vector3)
      • MatchOriginUpCameraForward(Vector3, Vector3)
      • MatchOriginUpOriginForward(Vector3, Vector3)
      • MoveCameraToWorldLocation(Vector3)
      • OnDestroy()
      • OnDisable()
      • OnEnable()
      • OnValidate()
      • RotateAroundCameraPosition(Vector3, Single)
      • RotateAroundCameraUsingOriginUp(Single)
      • Start()
    • Events
      • TrackablesParentTransformChanged
    • Extension Methods
    Back to top
    Terms of use
    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