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
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
GetTrackerHand()
Returns the hand holding this controller, if known. See XRPositionalTracker.TrackerHand.
public XRPositionalTracker.TrackerHand GetTrackerHand()
Returns
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
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_nameName of the method to check for.
Returns
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_nameName of the signal to check for.
Returns
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_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsButtonPressed(StringName)
Returns true
if the button with the given name
is pressed.
public bool IsButtonPressed(StringName name)
Parameters
name
StringName
Returns
Events
ButtonPressed
Emitted when a button on this controller is pressed.
public event XRController3D.ButtonPressedEventHandler ButtonPressed
Event Type
ButtonReleased
Emitted when a button on this controller is released.
public event XRController3D.ButtonReleasedEventHandler ButtonReleased
Event Type
InputFloatChanged
Emitted when a trigger or similar input on this controller changes value.
public event XRController3D.InputFloatChangedEventHandler InputFloatChanged
Event Type
InputVector2Changed
Emitted when a thumbstick or thumbpad on this controller is moved.
public event XRController3D.InputVector2ChangedEventHandler InputVector2Changed