ARVRController

Inherits: Spatial < Node < Object

Category: Core

Brief Description

A spatial node representing a spatially tracked controller.

Member Functions

String get_controller_name ( ) const
int get_hand ( ) const
bool get_is_active ( ) const
float get_joystick_axis ( int axis ) const
int get_joystick_id ( ) const
int is_button_pressed ( int button ) const

Signals

  • button_pressed ( int button )

Emitted when a button on this controller is pressed.

  • button_release ( int button )

Emitted when a button on this controller is released.

Member Variables

  • int controller_id - The controller’s id. The first controller that the ARVRServer detects will have id 1, the second id 2, the third id 3, etc. When a controller is turned off, it’s slot is freed. This ensures controllers will keep the same id even when controllers with lower ids are turned off.
  • float rumble - The degree to which the tracker rumbles. Ranges from 0.0 to 1.0 with precision .01. If changed, updates ARVRPositionalTracker.rumble accordingly.

Description

This is a helper spatial node that is linked to the tracking of controllers. It also offers several handy pass throughs 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. Say your game always uses two controllers (one for each hand) you can predefine the controllers with id 1 and 2 and 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 ARVRController nodes to your scene.

The position of the controller node is automatically updated by the ARVR Server. This makes this node ideal to add child nodes to visualise the controller.

Member Function Description

  • String get_controller_name ( ) const

If active, returns the name of the associated controller if provided by the AR/VR SDK used.

  • int get_hand ( ) const

Returns the hand holding this controller, if known. See TRACKER_* constants in ARVRPositionalTracker.

  • bool get_is_active ( ) const

Returns true if the bound controller is active. ARVR systems attempt to track active controllers.

  • float get_joystick_axis ( int axis ) const

Returns the value of the given axis for things like triggers, touchpads, etc. that are embedded into the controller.

  • int get_joystick_id ( ) const

Returns the ID of the joystick object bound to this. Every controller tracked by the ARVR Server that has buttons and axis will also be registered as a joystick within Godot. This means that all the normal joystick tracking and input mapping will work for buttons and axis found on the AR/VR controllers. This ID is purely offered as information so you can link up the controller with its joystick entry.

  • int is_button_pressed ( int button ) const

Returns true if the button at index button is pressed.