class_collisionobject.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the CollisionObject.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_CollisionObject:
  6. CollisionObject
  7. ===============
  8. **Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`Area<class_Area>`, :ref:`PhysicsBody<class_PhysicsBody>`
  10. **Category:** Core
  11. Brief Description
  12. -----------------
  13. Base node for collision objects.
  14. Properties
  15. ----------
  16. +-------------------------+------------------------------------------------------------------------------------+
  17. | :ref:`bool<class_bool>` | :ref:`input_capture_on_drag<class_CollisionObject_property_input_capture_on_drag>` |
  18. +-------------------------+------------------------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`input_ray_pickable<class_CollisionObject_property_input_ray_pickable>` |
  20. +-------------------------+------------------------------------------------------------------------------------+
  21. Methods
  22. -------
  23. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`_input_event<class_CollisionObject_method__input_event>` **(** :ref:`Object<class_Object>` camera, :ref:`InputEvent<class_InputEvent>` event, :ref:`Vector3<class_Vector3>` click_position, :ref:`Vector3<class_Vector3>` click_normal, :ref:`int<class_int>` shape_idx **)** virtual |
  25. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`create_shape_owner<class_CollisionObject_method_create_shape_owner>` **(** :ref:`Object<class_Object>` owner **)** |
  27. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`RID<class_RID>` | :ref:`get_rid<class_CollisionObject_method_get_rid>` **(** **)** const |
  29. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Array<class_Array>` | :ref:`get_shape_owners<class_CollisionObject_method_get_shape_owners>` **(** **)** |
  31. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`is_shape_owner_disabled<class_CollisionObject_method_is_shape_owner_disabled>` **(** :ref:`int<class_int>` owner_id **)** const |
  33. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`remove_shape_owner<class_CollisionObject_method_remove_shape_owner>` **(** :ref:`int<class_int>` owner_id **)** |
  35. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`shape_find_owner<class_CollisionObject_method_shape_find_owner>` **(** :ref:`int<class_int>` shape_index **)** const |
  37. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`shape_owner_add_shape<class_CollisionObject_method_shape_owner_add_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`Shape<class_Shape>` shape **)** |
  39. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`shape_owner_clear_shapes<class_CollisionObject_method_shape_owner_clear_shapes>` **(** :ref:`int<class_int>` owner_id **)** |
  41. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Object<class_Object>` | :ref:`shape_owner_get_owner<class_CollisionObject_method_shape_owner_get_owner>` **(** :ref:`int<class_int>` owner_id **)** const |
  43. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Shape<class_Shape>` | :ref:`shape_owner_get_shape<class_CollisionObject_method_shape_owner_get_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const |
  45. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`shape_owner_get_shape_count<class_CollisionObject_method_shape_owner_get_shape_count>` **(** :ref:`int<class_int>` owner_id **)** const |
  47. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`shape_owner_get_shape_index<class_CollisionObject_method_shape_owner_get_shape_index>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const |
  49. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Transform<class_Transform>` | :ref:`shape_owner_get_transform<class_CollisionObject_method_shape_owner_get_transform>` **(** :ref:`int<class_int>` owner_id **)** const |
  51. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`shape_owner_remove_shape<class_CollisionObject_method_shape_owner_remove_shape>` **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** |
  53. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`shape_owner_set_disabled<class_CollisionObject_method_shape_owner_set_disabled>` **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` disabled **)** |
  55. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`shape_owner_set_transform<class_CollisionObject_method_shape_owner_set_transform>` **(** :ref:`int<class_int>` owner_id, :ref:`Transform<class_Transform>` transform **)** |
  57. +-----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. Signals
  59. -------
  60. .. _class_CollisionObject_signal_input_event:
  61. - **input_event** **(** :ref:`Node<class_Node>` camera, :ref:`InputEvent<class_InputEvent>` event, :ref:`Vector3<class_Vector3>` click_position, :ref:`Vector3<class_Vector3>` click_normal, :ref:`int<class_int>` shape_idx **)**
  62. Emitted when :ref:`_input_event<class_CollisionObject_method__input_event>` receives an event. See its description for details.
  63. ----
  64. .. _class_CollisionObject_signal_mouse_entered:
  65. - **mouse_entered** **(** **)**
  66. Emitted when the mouse pointer enters any of this object's shapes.
  67. ----
  68. .. _class_CollisionObject_signal_mouse_exited:
  69. - **mouse_exited** **(** **)**
  70. Emitted when the mouse pointer exits all this object's shapes.
  71. Description
  72. -----------
  73. CollisionObject is the base class for physics objects. It can hold any number of collision :ref:`Shape<class_Shape>`\ s. Each shape must be assigned to a *shape owner*. The CollisionObject can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the ``shape_owner_*`` methods.
  74. Property Descriptions
  75. ---------------------
  76. .. _class_CollisionObject_property_input_capture_on_drag:
  77. - :ref:`bool<class_bool>` **input_capture_on_drag**
  78. +----------+----------------------------------+
  79. | *Setter* | set_capture_input_on_drag(value) |
  80. +----------+----------------------------------+
  81. | *Getter* | get_capture_input_on_drag() |
  82. +----------+----------------------------------+
  83. If ``true``, the ``CollisionObject`` will continue to receive input events as the mouse is dragged across its shapes. Default value: ``false``.
  84. ----
  85. .. _class_CollisionObject_property_input_ray_pickable:
  86. - :ref:`bool<class_bool>` **input_ray_pickable**
  87. +----------+-------------------------+
  88. | *Setter* | set_ray_pickable(value) |
  89. +----------+-------------------------+
  90. | *Getter* | is_ray_pickable() |
  91. +----------+-------------------------+
  92. If ``true``, the :ref:`CollisionObject<class_CollisionObject>`'s shapes will respond to :ref:`RayCast<class_RayCast>`\ s. Default value: ``true``.
  93. Method Descriptions
  94. -------------------
  95. .. _class_CollisionObject_method__input_event:
  96. - void **_input_event** **(** :ref:`Object<class_Object>` camera, :ref:`InputEvent<class_InputEvent>` event, :ref:`Vector3<class_Vector3>` click_position, :ref:`Vector3<class_Vector3>` click_normal, :ref:`int<class_int>` shape_idx **)** virtual
  97. Accepts unhandled :ref:`InputEvent<class_InputEvent>`\ s. ``click_position`` is the clicked location in world space and ``click_normal`` is the normal vector extending from the clicked surface of the :ref:`Shape<class_Shape>` at ``shape_idx``. Connect to the ``input_event`` signal to easily pick up these events.
  98. ----
  99. .. _class_CollisionObject_method_create_shape_owner:
  100. - :ref:`int<class_int>` **create_shape_owner** **(** :ref:`Object<class_Object>` owner **)**
  101. Creates a new shape owner for the given object. Returns ``owner_id`` of the new owner for future reference.
  102. ----
  103. .. _class_CollisionObject_method_get_rid:
  104. - :ref:`RID<class_RID>` **get_rid** **(** **)** const
  105. Returns the object's :ref:`RID<class_RID>`.
  106. ----
  107. .. _class_CollisionObject_method_get_shape_owners:
  108. - :ref:`Array<class_Array>` **get_shape_owners** **(** **)**
  109. Returns an :ref:`Array<class_Array>` of ``owner_id`` identifiers. You can use these ids in other methods that take ``owner_id`` as an argument.
  110. ----
  111. .. _class_CollisionObject_method_is_shape_owner_disabled:
  112. - :ref:`bool<class_bool>` **is_shape_owner_disabled** **(** :ref:`int<class_int>` owner_id **)** const
  113. If ``true``, the shape owner and its shapes are disabled.
  114. ----
  115. .. _class_CollisionObject_method_remove_shape_owner:
  116. - void **remove_shape_owner** **(** :ref:`int<class_int>` owner_id **)**
  117. Removes the given shape owner.
  118. ----
  119. .. _class_CollisionObject_method_shape_find_owner:
  120. - :ref:`int<class_int>` **shape_find_owner** **(** :ref:`int<class_int>` shape_index **)** const
  121. Returns the ``owner_id`` of the given shape.
  122. ----
  123. .. _class_CollisionObject_method_shape_owner_add_shape:
  124. - void **shape_owner_add_shape** **(** :ref:`int<class_int>` owner_id, :ref:`Shape<class_Shape>` shape **)**
  125. Adds a :ref:`Shape<class_Shape>` to the shape owner.
  126. ----
  127. .. _class_CollisionObject_method_shape_owner_clear_shapes:
  128. - void **shape_owner_clear_shapes** **(** :ref:`int<class_int>` owner_id **)**
  129. Removes all shapes from the shape owner.
  130. ----
  131. .. _class_CollisionObject_method_shape_owner_get_owner:
  132. - :ref:`Object<class_Object>` **shape_owner_get_owner** **(** :ref:`int<class_int>` owner_id **)** const
  133. Returns the parent object of the given shape owner.
  134. ----
  135. .. _class_CollisionObject_method_shape_owner_get_shape:
  136. - :ref:`Shape<class_Shape>` **shape_owner_get_shape** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const
  137. Returns the :ref:`Shape<class_Shape>` with the given id from the given shape owner.
  138. ----
  139. .. _class_CollisionObject_method_shape_owner_get_shape_count:
  140. - :ref:`int<class_int>` **shape_owner_get_shape_count** **(** :ref:`int<class_int>` owner_id **)** const
  141. Returns the number of shapes the given shape owner contains.
  142. ----
  143. .. _class_CollisionObject_method_shape_owner_get_shape_index:
  144. - :ref:`int<class_int>` **shape_owner_get_shape_index** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)** const
  145. Returns the child index of the :ref:`Shape<class_Shape>` with the given id from the given shape owner.
  146. ----
  147. .. _class_CollisionObject_method_shape_owner_get_transform:
  148. - :ref:`Transform<class_Transform>` **shape_owner_get_transform** **(** :ref:`int<class_int>` owner_id **)** const
  149. Returns the shape owner's :ref:`Transform<class_Transform>`.
  150. ----
  151. .. _class_CollisionObject_method_shape_owner_remove_shape:
  152. - void **shape_owner_remove_shape** **(** :ref:`int<class_int>` owner_id, :ref:`int<class_int>` shape_id **)**
  153. Removes a shape from the given shape owner.
  154. ----
  155. .. _class_CollisionObject_method_shape_owner_set_disabled:
  156. - void **shape_owner_set_disabled** **(** :ref:`int<class_int>` owner_id, :ref:`bool<class_bool>` disabled **)**
  157. If ``true``, disables the given shape owner.
  158. ----
  159. .. _class_CollisionObject_method_shape_owner_set_transform:
  160. - void **shape_owner_set_transform** **(** :ref:`int<class_int>` owner_id, :ref:`Transform<class_Transform>` transform **)**
  161. Sets the :ref:`Transform<class_Transform>` of the given shape owner.