docs.unity3d.com
    Show / Hide Table of Contents

    Class ActionBasedController

    Interprets feature values on a tracked input controller device using actions from the Input System into XR Interaction states, such as Select. Additionally, it applies the current Pose value of a tracked device to the transform of the GameObject.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    XRBaseController
    ActionBasedController
    Inherited Members
    XRBaseController.updateTrackingType
    XRBaseController.enableInputTracking
    XRBaseController.enableInputActions
    XRBaseController.modelPrefab
    XRBaseController.modelParent
    XRBaseController.model
    XRBaseController.animateModel
    XRBaseController.modelSelectTransition
    XRBaseController.modelDeSelectTransition
    XRBaseController.hideControllerModel
    XRBaseController.selectInteractionState
    XRBaseController.activateInteractionState
    XRBaseController.uiPressInteractionState
    XRBaseController.uiScrollValue
    XRBaseController.currentControllerState
    XRBaseController.Awake()
    XRBaseController.Update()
    XRBaseController.GetModelPrefab()
    XRBaseController.UpdateController()
    XRBaseController.OnBeforeRender()
    XRBaseController.FixedUpdate()
    XRBaseController.ApplyControllerState(XRInteractionUpdateOrder.UpdatePhase, XRControllerState)
    XRBaseController.UpdateControllerModelAnimation()
    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.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, Boolean)
    Component.GetComponentInParent(Type)
    UnityEngine.Component.GetComponentInParent<T>(System.Boolean)
    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
    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.FindObjectsOfType(Type, Boolean)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsSortMode)
    UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsInactive, UnityEngine.FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
    UnityEngine.Object.FindFirstObjectByType<T>()
    UnityEngine.Object.FindAnyObjectByType<T>()
    UnityEngine.Object.FindFirstObjectByType<T>(UnityEngine.FindObjectsInactive)
    UnityEngine.Object.FindAnyObjectByType<T>(UnityEngine.FindObjectsInactive)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, Boolean)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    [AddComponentMenu("XR/XR Controller (Action-based)", 11)]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.4/api/UnityEngine.XR.Interaction.Toolkit.ActionBasedController.html")]
    public class ActionBasedController : XRBaseController
    Remarks

    This behavior requires that the Input System is enabled in the Active Input Handling setting in Edit > Project Settings > Player for input values to be read. Each input action must also be enabled to read the current value of the action. Referenced input actions in an Input Action Asset are not enabled by default.

    Properties

    activateAction

    The Input System action to use for activating a selected Interactable. Must be an action with a button-like interaction where phase equals performed when pressed. Typically a ButtonControl Control or a Value type action with a Press or Sector interaction.

    Declaration
    public InputActionProperty activateAction { get; set; }
    Property Value
    Type Description
    InputActionProperty
    See Also
    activateActionValue

    activateActionValue

    The Input System action to read values for activating a selected Interactable. Must be an AxisControl Control or Vector2Control Control.

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

    Optional, Unity uses activateAction when not set.

    See Also
    activateAction

    directionalAnchorRotationAction

    The Input System action to use for computing a direction angle to rotate the interactor's attach point to match it. Must be a Vector2Control Control. The direction angle should be computed as the arctangent function of x/y.

    Declaration
    public InputActionProperty directionalAnchorRotationAction { get; set; }
    Property Value
    Type Description
    InputActionProperty

    hapticDeviceAction

    The Input System action to use for identifying the device to send haptic impulses to. Can be any control type that will have an active control driving the action.

    Declaration
    public InputActionProperty hapticDeviceAction { get; set; }
    Property Value
    Type Description
    InputActionProperty

    isTrackedAction

    The Input System action to read the Is Tracked state when updating this GameObject position and rotation; falls back to the tracked device's is tracked state that drives the position or rotation action when not set. Must be an action with a button-like interaction where phase equals performed when is tracked. Typically a ButtonControl Control.

    Declaration
    public InputActionProperty isTrackedAction { get; set; }
    Property Value
    Type Description
    InputActionProperty

    positionAction

    The Input System action to use for Position Tracking for this GameObject. Must be a Vector3Control Control.

    Declaration
    public InputActionProperty positionAction { get; set; }
    Property Value
    Type Description
    InputActionProperty

    rotateAnchorAction

    The Input System action to use for rotating the interactor's attach point over time. Must be a Vector2Control Control. Uses the x-axis as the rotation input.

    Declaration
    public InputActionProperty rotateAnchorAction { get; set; }
    Property Value
    Type Description
    InputActionProperty

    rotationAction

    The Input System action to use for Rotation Tracking for this GameObject. Must be a QuaternionControl Control.

    Declaration
    public InputActionProperty rotationAction { get; set; }
    Property Value
    Type Description
    InputActionProperty

    selectAction

    The Input System action to use for selecting an Interactable. Must be an action with a button-like interaction where phase equals performed when pressed. Typically a ButtonControl Control or a Value type action with a Press or Sector interaction.

    Declaration
    public InputActionProperty selectAction { get; set; }
    Property Value
    Type Description
    InputActionProperty
    See Also
    selectActionValue

    selectActionValue

    The Input System action to read values for selecting an Interactable. Must be an AxisControl Control or Vector2Control Control.

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

    Optional, Unity uses selectAction when not set.

    See Also
    selectAction

    trackingStateAction

    The Input System action to read the Tracking State when updating this GameObject position and rotation; falls back to the tracked device's tracking state that drives the position or rotation action when not set. Must be an IntegerControl Control.

    Declaration
    public InputActionProperty trackingStateAction { get; set; }
    Property Value
    Type Description
    InputActionProperty
    See Also
    InputTrackingState

    translateAnchorAction

    The Input System action to use for translating the interactor's attach point closer or further away from the interactor. Must be a Vector2Control Control. Uses the y-axis as the translation input.

    Declaration
    public InputActionProperty translateAnchorAction { get; set; }
    Property Value
    Type Description
    InputActionProperty

    uiPressAction

    The Input System action to use for Canvas UI interaction. Must be an action with a button-like interaction where phase equals performed when pressed. Typically a ButtonControl Control or a Value type action with a Press interaction.

    Declaration
    public InputActionProperty uiPressAction { get; set; }
    Property Value
    Type Description
    InputActionProperty
    See Also
    uiPressActionValue

    uiPressActionValue

    The Input System action to read values for Canvas UI interaction. Must be an AxisControl Control or Vector2Control Control.

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

    Optional, Unity uses uiPressAction when not set.

    See Also
    uiPressAction

    uiScrollAction

    The Input System action to read values for Canvas UI scrolling. Must be a Vector2Control Control.

    Declaration
    public InputActionProperty uiScrollAction { get; set; }
    Property Value
    Type Description
    InputActionProperty
    See Also
    uiPressAction

    Methods

    IsPressed(InputAction)

    Evaluates whether the given input action is considered performed. Unity automatically calls this method during UpdateInput(XRControllerState) to determine if the interaction state is active this frame.

    Declaration
    protected virtual bool IsPressed(InputAction action)
    Parameters
    Type Name Description
    InputAction action

    The input action to check.

    Returns
    Type Description
    Boolean

    Returns true when the input action is considered performed. Otherwise, returns false.

    Remarks

    More accurately, this evaluates whether the action with a button-like interaction is performed. Depending on the interaction of the input action, the control driving the value of the input action may technically be pressed and though the interaction may be in progress, it may not yet be performed, such as for a Hold interaction. In that example, this method returns false.

    See Also
    active

    OnDisable()

    See MonoBehaviour.

    Declaration
    protected override void OnDisable()
    Overrides
    XRBaseController.OnDisable()

    OnEnable()

    See MonoBehaviour.

    Declaration
    protected override void OnEnable()
    Overrides
    XRBaseController.OnEnable()

    ReadValue(InputAction)

    Reads and returns the given action value. Unity automatically calls this method during UpdateInput(XRControllerState) to determine the amount or strength of the interaction state this frame.

    Declaration
    protected virtual float ReadValue(InputAction action)
    Parameters
    Type Name Description
    InputAction action

    The action to read the value from.

    Returns
    Type Description
    Single

    Returns the action value. If the action is null returns the default float value (0f).

    See Also
    value

    SendHapticImpulse(Single, Single)

    Play a haptic impulse on the controller if one is available.

    Declaration
    public override bool SendHapticImpulse(float amplitude, float duration)
    Parameters
    Type Name Description
    Single amplitude

    Amplitude (from 0.0 to 1.0) to play impulse at.

    Single duration

    Duration (in seconds) to play haptic impulse.

    Returns
    Type Description
    Boolean

    Returns true if successful. Otherwise, returns false.

    Overrides
    XRBaseController.SendHapticImpulse(Single, Single)

    UpdateInput(XRControllerState)

    Updates the XR Interaction states in the given controller state based on the current inputs of the controller device. Unity calls this automatically during UpdateController() so explicit calls to this function are not required.

    Declaration
    protected override void UpdateInput(XRControllerState controllerState)
    Parameters
    Type Name Description
    XRControllerState controllerState

    The state of the controller.

    Overrides
    XRBaseController.UpdateInput(XRControllerState)

    UpdateTrackingInput(XRControllerState)

    Updates the pose values in the given controller state based on the current tracking input of the controller device. Unity calls this automatically from FixedUpdate(), OnBeforeRender(), and UpdateController() so explicit calls to this function are not required.

    Declaration
    protected override void UpdateTrackingInput(XRControllerState controllerState)
    Parameters
    Type Name Description
    XRControllerState controllerState

    The state of the controller.

    Overrides
    XRBaseController.UpdateTrackingInput(XRControllerState)

    See Also

    XRBaseController

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Properties
      • activateAction
      • activateActionValue
      • directionalAnchorRotationAction
      • hapticDeviceAction
      • isTrackedAction
      • positionAction
      • rotateAnchorAction
      • rotationAction
      • selectAction
      • selectActionValue
      • trackingStateAction
      • translateAnchorAction
      • uiPressAction
      • uiPressActionValue
      • uiScrollAction
    • Methods
      • IsPressed(InputAction)
      • OnDisable()
      • OnEnable()
      • ReadValue(InputAction)
      • SendHapticImpulse(Single, Single)
      • UpdateInput(XRControllerState)
      • UpdateTrackingInput(XRControllerState)
    • See Also
    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