class_arvrcontroller.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/ARVRController.xml.
  6. .. _class_ARVRController:
  7. ARVRController
  8. ==============
  9. **Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A spatial node representing a spatially-tracked controller.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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.
  15. 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.
  16. 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.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`../tutorials/vr/index`
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +---------------------------+-------------------------------------------------------------------+---------+
  27. | :ref:`int<class_int>` | :ref:`controller_id<class_ARVRController_property_controller_id>` | ``1`` |
  28. +---------------------------+-------------------------------------------------------------------+---------+
  29. | :ref:`float<class_float>` | :ref:`rumble<class_ARVRController_property_rumble>` | ``0.0`` |
  30. +---------------------------+-------------------------------------------------------------------+---------+
  31. .. rst-class:: classref-reftable-group
  32. Methods
  33. -------
  34. .. table::
  35. :widths: auto
  36. +------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`String<class_String>` | :ref:`get_controller_name<class_ARVRController_method_get_controller_name>` **(** **)** |const| |
  38. +------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`TrackerHand<enum_ARVRPositionalTracker_TrackerHand>` | :ref:`get_hand<class_ARVRController_method_get_hand>` **(** **)** |const| |
  40. +------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`get_is_active<class_ARVRController_method_get_is_active>` **(** **)** |const| |
  42. +------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`float<class_float>` | :ref:`get_joystick_axis<class_ARVRController_method_get_joystick_axis>` **(** :ref:`int<class_int>` axis **)** |const| |
  44. +------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`int<class_int>` | :ref:`get_joystick_id<class_ARVRController_method_get_joystick_id>` **(** **)** |const| |
  46. +------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Mesh<class_Mesh>` | :ref:`get_mesh<class_ARVRController_method_get_mesh>` **(** **)** |const| |
  48. +------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`int<class_int>` | :ref:`is_button_pressed<class_ARVRController_method_is_button_pressed>` **(** :ref:`int<class_int>` button **)** |const| |
  50. +------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------+
  51. .. rst-class:: classref-section-separator
  52. ----
  53. .. rst-class:: classref-descriptions-group
  54. Signals
  55. -------
  56. .. _class_ARVRController_signal_button_pressed:
  57. .. rst-class:: classref-signal
  58. **button_pressed** **(** :ref:`int<class_int>` button **)**
  59. Emitted when a button on this controller is pressed.
  60. .. rst-class:: classref-item-separator
  61. ----
  62. .. _class_ARVRController_signal_button_release:
  63. .. rst-class:: classref-signal
  64. **button_release** **(** :ref:`int<class_int>` button **)**
  65. Emitted when a button on this controller is released.
  66. .. rst-class:: classref-item-separator
  67. ----
  68. .. _class_ARVRController_signal_mesh_updated:
  69. .. rst-class:: classref-signal
  70. **mesh_updated** **(** :ref:`Mesh<class_Mesh>` mesh **)**
  71. 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.
  72. .. rst-class:: classref-section-separator
  73. ----
  74. .. rst-class:: classref-descriptions-group
  75. Property Descriptions
  76. ---------------------
  77. .. _class_ARVRController_property_controller_id:
  78. .. rst-class:: classref-property
  79. :ref:`int<class_int>` **controller_id** = ``1``
  80. .. rst-class:: classref-property-setget
  81. - void **set_controller_id** **(** :ref:`int<class_int>` value **)**
  82. - :ref:`int<class_int>` **get_controller_id** **(** **)**
  83. The controller's ID.
  84. 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.
  85. For any other controller that the :ref:`ARVRServer<class_ARVRServer>` detects, we continue with controller ID 3.
  86. 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.
  87. .. rst-class:: classref-item-separator
  88. ----
  89. .. _class_ARVRController_property_rumble:
  90. .. rst-class:: classref-property
  91. :ref:`float<class_float>` **rumble** = ``0.0``
  92. .. rst-class:: classref-property-setget
  93. - void **set_rumble** **(** :ref:`float<class_float>` value **)**
  94. - :ref:`float<class_float>` **get_rumble** **(** **)**
  95. 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.
  96. This is a useful property to animate if you want the controller to vibrate for a limited duration.
  97. .. rst-class:: classref-section-separator
  98. ----
  99. .. rst-class:: classref-descriptions-group
  100. Method Descriptions
  101. -------------------
  102. .. _class_ARVRController_method_get_controller_name:
  103. .. rst-class:: classref-method
  104. :ref:`String<class_String>` **get_controller_name** **(** **)** |const|
  105. If active, returns the name of the associated controller if provided by the AR/VR SDK used.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_ARVRController_method_get_hand:
  109. .. rst-class:: classref-method
  110. :ref:`TrackerHand<enum_ARVRPositionalTracker_TrackerHand>` **get_hand** **(** **)** |const|
  111. Returns the hand holding this controller, if known. See :ref:`TrackerHand<enum_ARVRPositionalTracker_TrackerHand>`.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_ARVRController_method_get_is_active:
  115. .. rst-class:: classref-method
  116. :ref:`bool<class_bool>` **get_is_active** **(** **)** |const|
  117. Returns ``true`` if the bound controller is active. ARVR systems attempt to track active controllers.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_ARVRController_method_get_joystick_axis:
  121. .. rst-class:: classref-method
  122. :ref:`float<class_float>` **get_joystick_axis** **(** :ref:`int<class_int>` axis **)** |const|
  123. Returns the value of the given axis for things like triggers, touchpads, etc. that are embedded into the controller.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_ARVRController_method_get_joystick_id:
  127. .. rst-class:: classref-method
  128. :ref:`int<class_int>` **get_joystick_id** **(** **)** |const|
  129. 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.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_ARVRController_method_get_mesh:
  133. .. rst-class:: classref-method
  134. :ref:`Mesh<class_Mesh>` **get_mesh** **(** **)** |const|
  135. If provided by the :ref:`ARVRInterface<class_ARVRInterface>`, this returns a mesh associated with the controller. This can be used to visualize the controller.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_ARVRController_method_is_button_pressed:
  139. .. rst-class:: classref-method
  140. :ref:`int<class_int>` **is_button_pressed** **(** :ref:`int<class_int>` button **)** |const|
  141. Returns ``true`` if the button at index ``button`` is pressed. See :ref:`JoystickList<enum_@GlobalScope_JoystickList>`, in particular the ``JOY_VR_*`` constants.
  142. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  143. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  144. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  145. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`