XRController3D

继承: XRNode3D < Node3D < Node < Object

A spatial node representing a spatially-tracked controller.

描述

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.

方法


信号

button_pressed ( name: String )

Emitted when a button on this controller is pressed.


button_released ( name: String )

Emitted when a button on this controller is released.


input_float_changed ( name: String, value: float )

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


input_vector2_changed ( name: String, value: Vector2 )

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


profile_changed ( role: String )

Emitted when the interaction profile on this controller is changed.


方法说明

float get_float ( name: StringName ) const1

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


Variant get_input ( name: StringName ) const1

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.


TrackerHand get_tracker_hand ( ) const1

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


Vector2 get_vector2 ( name: StringName ) const1

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


bool is_button_pressed ( name: StringName ) const1

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

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。