virtualx-engine-docs/_sources/classes/class_arvrcontroller.rst.txt

254 lines
10 KiB
Text
Raw Normal View History

2024-10-23 18:41:33 +02:00
:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/ARVRController.xml.
.. _class_ARVRController:
ARVRController
==============
**Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
A spatial node representing a spatially-tracked controller.
.. rst-class:: classref-introduction-group
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 ARVRController nodes to your scene.
The position of the controller node is automatically updated by the :ref:`ARVRServer<class_ARVRServer>`. This makes this node ideal to add child nodes to visualize the controller.
.. rst-class:: classref-introduction-group
Tutorials
---------
- :doc:`../tutorials/vr/index`
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+---------------------------+-------------------------------------------------------------------+---------+
| :ref:`int<class_int>` | :ref:`controller_id<class_ARVRController_property_controller_id>` | ``1`` |
+---------------------------+-------------------------------------------------------------------+---------+
| :ref:`float<class_float>` | :ref:`rumble<class_ARVRController_property_rumble>` | ``0.0`` |
+---------------------------+-------------------------------------------------------------------+---------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_controller_name<class_ARVRController_method_get_controller_name>` **(** **)** |const| |
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
| :ref:`TrackerHand<enum_ARVRPositionalTracker_TrackerHand>` | :ref:`get_hand<class_ARVRController_method_get_hand>` **(** **)** |const| |
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`get_is_active<class_ARVRController_method_get_is_active>` **(** **)** |const| |
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_joystick_axis<class_ARVRController_method_get_joystick_axis>` **(** :ref:`int<class_int>` axis **)** |const| |
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_joystick_id<class_ARVRController_method_get_joystick_id>` **(** **)** |const| |
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
| :ref:`Mesh<class_Mesh>` | :ref:`get_mesh<class_ARVRController_method_get_mesh>` **(** **)** |const| |
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`is_button_pressed<class_ARVRController_method_is_button_pressed>` **(** :ref:`int<class_int>` button **)** |const| |
+------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Signals
-------
.. _class_ARVRController_signal_button_pressed:
.. rst-class:: classref-signal
**button_pressed** **(** :ref:`int<class_int>` button **)**
Emitted when a button on this controller is pressed.
.. rst-class:: classref-item-separator
----
.. _class_ARVRController_signal_button_release:
.. rst-class:: classref-signal
**button_release** **(** :ref:`int<class_int>` button **)**
Emitted when a button on this controller is released.
.. rst-class:: classref-item-separator
----
.. _class_ARVRController_signal_mesh_updated:
.. rst-class:: classref-signal
**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.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_ARVRController_property_controller_id:
.. rst-class:: classref-property
:ref:`int<class_int>` **controller_id** = ``1``
.. rst-class:: classref-property-setget
- void **set_controller_id** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **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:`ARVRServer<class_ARVRServer>` 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.
.. rst-class:: classref-item-separator
----
.. _class_ARVRController_property_rumble:
.. rst-class:: classref-property
:ref:`float<class_float>` **rumble** = ``0.0``
.. rst-class:: classref-property-setget
- void **set_rumble** **(** :ref:`float<class_float>` value **)**
- :ref:`float<class_float>` **get_rumble** **(** **)**
The degree to which the controller vibrates. Ranges from ``0.0`` to ``1.0``. If changed, updates :ref:`ARVRPositionalTracker.rumble<class_ARVRPositionalTracker_property_rumble>` accordingly.
This is a useful property to animate if you want the controller to vibrate for a limited duration.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_ARVRController_method_get_controller_name:
.. rst-class:: classref-method
: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.
.. rst-class:: classref-item-separator
----
.. _class_ARVRController_method_get_hand:
.. rst-class:: classref-method
:ref:`TrackerHand<enum_ARVRPositionalTracker_TrackerHand>` **get_hand** **(** **)** |const|
Returns the hand holding this controller, if known. See :ref:`TrackerHand<enum_ARVRPositionalTracker_TrackerHand>`.
.. rst-class:: classref-item-separator
----
.. _class_ARVRController_method_get_is_active:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **get_is_active** **(** **)** |const|
Returns ``true`` if the bound controller is active. ARVR systems attempt to track active controllers.
.. rst-class:: classref-item-separator
----
.. _class_ARVRController_method_get_joystick_axis:
.. rst-class:: classref-method
: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.
.. rst-class:: classref-item-separator
----
.. _class_ARVRController_method_get_joystick_id:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_joystick_id** **(** **)** |const|
Returns the ID of the joystick object bound to this. Every controller tracked by the :ref:`ARVRServer<class_ARVRServer>` 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.
.. rst-class:: classref-item-separator
----
.. _class_ARVRController_method_get_mesh:
.. rst-class:: classref-method
:ref:`Mesh<class_Mesh>` **get_mesh** **(** **)** |const|
If provided by the :ref:`ARVRInterface<class_ARVRInterface>`, this returns a mesh associated with the controller. This can be used to visualize the controller.
.. rst-class:: classref-item-separator
----
.. _class_ARVRController_method_is_button_pressed:
.. rst-class:: classref-method
:ref:`int<class_int>` **is_button_pressed** **(** :ref:`int<class_int>` button **)** |const|
Returns ``true`` if the button at index ``button`` is pressed. See :ref:`JoystickList<enum_@GlobalScope_JoystickList>`, in particular the ``JOY_VR_*`` constants.
.. |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.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`