XRController3D

Inherits: XRNode3D < Node3D < Node < Object

A spatial node representing a spatially-tracked controller.

Description

This is a helper spatial node that is linked to the tracking of controllers. It also offers several handy passthroughs to the state of buttons and such on the controllers.

Controllers are linked by their ID. You can create controller nodes before the controllers are available. If your game always uses two controllers (one for each hand), you can predefine the controllers with ID 1 and 2; they will become active as soon as the controllers are identified. If you expect additional controllers to be used, you should react to the signals and add XRController3D nodes to your scene.

The position of the controller node is automatically updated by the XRServer. This makes this node ideal to add child nodes to visualize the controller.

As many XR runtimes now use a configurable action map all inputs are named.

Properties

float

rumble

0.0

Methods

Vector2

get_axis ( StringName name ) const

TrackerHand

get_tracker_hand ( ) const

float

get_value ( StringName name ) const

bool

is_button_pressed ( StringName name ) const

Signals

  • button_pressed ( String name )

Emitted when a button on this controller is pressed.


  • button_released ( String name )

Emitted when a button on this controller is released.


Emitted when a thumbstick or thumbpad on this controller is moved.


Emitted when a trigger or similar input on this controller changes value.

Property Descriptions

Default

0.0

Setter

set_rumble(value)

Getter

get_rumble()

The degree to which the controller vibrates. Ranges from 0.0 to 1.0 with precision .01. If changed, updates XRPositionalTracker.rumble accordingly.

This is a useful property to animate if you want the controller to vibrate for a limited duration.

Method Descriptions

Returns a Vector2 for the input with the given name. This is used for thumbsticks and thumbpads found on many controllers.


Returns the hand holding this controller, if known. See TrackerHand.


Returns a numeric value for the input with the given name. This is used for triggers and grip sensors.


Returns true if the button with the given name is pressed.