mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-08 19:29:06 +00:00
187 lines
9.5 KiB
ReStructuredText
187 lines
9.5 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the XRController3D.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_XRController3D:
|
|
|
|
XRController3D
|
|
==============
|
|
|
|
**Inherits:** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_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 :ref:`XRServer<class_XRServer>`. This makes this node ideal to add child nodes to visualize the controller.
|
|
|
|
Tutorials
|
|
---------
|
|
|
|
- :doc:`../tutorials/vr/index`
|
|
|
|
Properties
|
|
----------
|
|
|
|
+---------------------------+-------------------------------------------------------------------+---------+
|
|
| :ref:`int<class_int>` | :ref:`controller_id<class_XRController3D_property_controller_id>` | ``1`` |
|
|
+---------------------------+-------------------------------------------------------------------+---------+
|
|
| :ref:`float<class_float>` | :ref:`rumble<class_XRController3D_property_rumble>` | ``0.0`` |
|
|
+---------------------------+-------------------------------------------------------------------+---------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_controller_name<class_XRController3D_method_get_controller_name>` **(** **)** |const| |
|
|
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`get_is_active<class_XRController3D_method_get_is_active>` **(** **)** |const| |
|
|
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_joystick_axis<class_XRController3D_method_get_joystick_axis>` **(** :ref:`int<class_int>` axis **)** |const| |
|
|
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_joystick_id<class_XRController3D_method_get_joystick_id>` **(** **)** |const| |
|
|
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Mesh<class_Mesh>` | :ref:`get_mesh<class_XRController3D_method_get_mesh>` **(** **)** |const| |
|
|
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`TrackerHand<enum_XRPositionalTracker_TrackerHand>` | :ref:`get_tracker_hand<class_XRController3D_method_get_tracker_hand>` **(** **)** |const| |
|
|
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_button_pressed<class_XRController3D_method_is_button_pressed>` **(** :ref:`int<class_int>` button **)** |const| |
|
|
+----------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Signals
|
|
-------
|
|
|
|
.. _class_XRController3D_signal_button_pressed:
|
|
|
|
- **button_pressed** **(** :ref:`int<class_int>` button **)**
|
|
|
|
Emitted when a button on this controller is pressed.
|
|
|
|
----
|
|
|
|
.. _class_XRController3D_signal_button_released:
|
|
|
|
- **button_released** **(** :ref:`int<class_int>` button **)**
|
|
|
|
Emitted when a button on this controller is released.
|
|
|
|
----
|
|
|
|
.. _class_XRController3D_signal_mesh_updated:
|
|
|
|
- **mesh_updated** **(** :ref:`Mesh<class_Mesh>` mesh **)**
|
|
|
|
Emitted when the mesh associated with the controller changes or when one becomes available. Generally speaking this will be a static mesh after becoming available.
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_XRController3D_property_controller_id:
|
|
|
|
- :ref:`int<class_int>` **controller_id**
|
|
|
|
+-----------+--------------------------+
|
|
| *Default* | ``1`` |
|
|
+-----------+--------------------------+
|
|
| *Setter* | set_controller_id(value) |
|
|
+-----------+--------------------------+
|
|
| *Getter* | get_controller_id() |
|
|
+-----------+--------------------------+
|
|
|
|
The controller's ID.
|
|
|
|
A controller ID of 0 is unbound and will always result in an inactive node. Controller ID 1 is reserved for the first controller that identifies itself as the left-hand controller and ID 2 is reserved for the first controller that identifies itself as the right-hand controller.
|
|
|
|
For any other controller that the :ref:`XRServer<class_XRServer>` detects, we continue with controller ID 3.
|
|
|
|
When a controller is turned off, its slot is freed. This ensures controllers will keep the same ID even when controllers with lower IDs are turned off.
|
|
|
|
----
|
|
|
|
.. _class_XRController3D_property_rumble:
|
|
|
|
- :ref:`float<class_float>` **rumble**
|
|
|
|
+-----------+-------------------+
|
|
| *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 :ref:`XRPositionalTracker.rumble<class_XRPositionalTracker_property_rumble>` accordingly.
|
|
|
|
This is a useful property to animate if you want the controller to vibrate for a limited duration.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_XRController3D_method_get_controller_name:
|
|
|
|
- :ref:`String<class_String>` **get_controller_name** **(** **)** |const|
|
|
|
|
If active, returns the name of the associated controller if provided by the AR/VR SDK used.
|
|
|
|
----
|
|
|
|
.. _class_XRController3D_method_get_is_active:
|
|
|
|
- :ref:`bool<class_bool>` **get_is_active** **(** **)** |const|
|
|
|
|
Returns ``true`` if the bound controller is active. XR systems attempt to track active controllers.
|
|
|
|
----
|
|
|
|
.. _class_XRController3D_method_get_joystick_axis:
|
|
|
|
- :ref:`float<class_float>` **get_joystick_axis** **(** :ref:`int<class_int>` axis **)** |const|
|
|
|
|
Returns the value of the given axis for things like triggers, touchpads, etc. that are embedded into the controller.
|
|
|
|
----
|
|
|
|
.. _class_XRController3D_method_get_joystick_id:
|
|
|
|
- :ref:`int<class_int>` **get_joystick_id** **(** **)** |const|
|
|
|
|
Returns the ID of the joystick object bound to this. Every controller tracked by the :ref:`XRServer<class_XRServer>` 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.
|
|
|
|
----
|
|
|
|
.. _class_XRController3D_method_get_mesh:
|
|
|
|
- :ref:`Mesh<class_Mesh>` **get_mesh** **(** **)** |const|
|
|
|
|
If provided by the :ref:`XRInterface<class_XRInterface>`, this returns a mesh associated with the controller. This can be used to visualize the controller.
|
|
|
|
----
|
|
|
|
.. _class_XRController3D_method_get_tracker_hand:
|
|
|
|
- :ref:`TrackerHand<enum_XRPositionalTracker_TrackerHand>` **get_tracker_hand** **(** **)** |const|
|
|
|
|
Returns the hand holding this controller, if known. See :ref:`TrackerHand<enum_XRPositionalTracker_TrackerHand>`.
|
|
|
|
----
|
|
|
|
.. _class_XRController3D_method_is_button_pressed:
|
|
|
|
- :ref:`bool<class_bool>` **is_button_pressed** **(** :ref:`int<class_int>` button **)** |const|
|
|
|
|
Returns ``true`` if the button at index ``button`` is pressed. See :ref:`JoyButton<enum_@GlobalScope_JoyButton>`.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
|
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
|
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|
|
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|