Table of Contents

Class XRController3D

Namespace
Godot
Assembly
GodotSharp.dll

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.

public class XRController3D : XRNode3D, IDisposable
Inheritance
XRController3D
Implements
Inherited Members

Constructors

XRController3D()

public XRController3D()

Methods

GetFloat(StringName)

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

public float GetFloat(StringName name)

Parameters

name StringName

Returns

float

GetInput(StringName)

Returns a Variant for the input with the given name. This works for any input type, the variant will be typed according to the actions configuration.

public Variant GetInput(StringName name)

Parameters

name StringName

Returns

Variant

GetTrackerHand()

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

public XRPositionalTracker.TrackerHand GetTrackerHand()

Returns

XRPositionalTracker.TrackerHand

GetVector2(StringName)

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

public Vector2 GetVector2(StringName name)

Parameters

name StringName

Returns

Vector2

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsButtonPressed(StringName)

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

public bool IsButtonPressed(StringName name)

Parameters

name StringName

Returns

bool

Events

ButtonPressed

Emitted when a button on this controller is pressed.

public event XRController3D.ButtonPressedEventHandler ButtonPressed

Event Type

XRController3D.ButtonPressedEventHandler

ButtonReleased

Emitted when a button on this controller is released.

public event XRController3D.ButtonReleasedEventHandler ButtonReleased

Event Type

XRController3D.ButtonReleasedEventHandler

InputFloatChanged

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

public event XRController3D.InputFloatChangedEventHandler InputFloatChanged

Event Type

XRController3D.InputFloatChangedEventHandler

InputVector2Changed

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

public event XRController3D.InputVector2ChangedEventHandler InputVector2Changed

Event Type

XRController3D.InputVector2ChangedEventHandler