class_area2d.rst 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. :github_url: hide
  2. .. meta::
  3. :keywords: trigger
  4. .. DO NOT EDIT THIS FILE!!!
  5. .. Generated automatically from Godot engine sources.
  6. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  7. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Area2D.xml.
  8. .. _class_Area2D:
  9. Area2D
  10. ======
  11. **Inherits:** :ref:`CollisionObject2D<class_CollisionObject2D>` **<** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  12. A region of 2D space that detects other :ref:`CollisionObject2D<class_CollisionObject2D>`\ s entering or exiting it.
  13. .. rst-class:: classref-introduction-group
  14. Description
  15. -----------
  16. **Area2D** is a region of 2D space defined by one or multiple :ref:`CollisionShape2D<class_CollisionShape2D>` or :ref:`CollisionPolygon2D<class_CollisionPolygon2D>` child nodes. It detects when other :ref:`CollisionObject2D<class_CollisionObject2D>`\ s enter or exit it, and it also keeps track of which collision objects haven't exited it yet (i.e. which one are overlapping it).
  17. This node can also locally alter or override physics parameters (gravity, damping) and route audio to custom audio buses.
  18. \ **Note:** Areas and bodies created with :ref:`PhysicsServer2D<class_PhysicsServer2D>` might not interact as expected with **Area2D**\ s, and might not emit signals or track objects correctly.
  19. .. rst-class:: classref-introduction-group
  20. Tutorials
  21. ---------
  22. - :doc:`Using Area2D <../tutorials/physics/using_area_2d>`
  23. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/2712>`__
  24. - `2D Pong Demo <https://godotengine.org/asset-library/asset/2728>`__
  25. - `2D Platformer Demo <https://godotengine.org/asset-library/asset/2727>`__
  26. .. rst-class:: classref-reftable-group
  27. Properties
  28. ----------
  29. .. table::
  30. :widths: auto
  31. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  32. | :ref:`float<class_float>` | :ref:`angular_damp<class_Area2D_property_angular_damp>` | ``1.0`` |
  33. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  34. | :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` | :ref:`angular_damp_space_override<class_Area2D_property_angular_damp_space_override>` | ``0`` |
  35. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  36. | :ref:`StringName<class_StringName>` | :ref:`audio_bus_name<class_Area2D_property_audio_bus_name>` | ``&"Master"`` |
  37. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  38. | :ref:`bool<class_bool>` | :ref:`audio_bus_override<class_Area2D_property_audio_bus_override>` | ``false`` |
  39. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  40. | :ref:`float<class_float>` | :ref:`gravity<class_Area2D_property_gravity>` | ``980.0`` |
  41. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  42. | :ref:`Vector2<class_Vector2>` | :ref:`gravity_direction<class_Area2D_property_gravity_direction>` | ``Vector2(0, 1)`` |
  43. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  44. | :ref:`bool<class_bool>` | :ref:`gravity_point<class_Area2D_property_gravity_point>` | ``false`` |
  45. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  46. | :ref:`Vector2<class_Vector2>` | :ref:`gravity_point_center<class_Area2D_property_gravity_point_center>` | ``Vector2(0, 1)`` |
  47. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  48. | :ref:`float<class_float>` | :ref:`gravity_point_unit_distance<class_Area2D_property_gravity_point_unit_distance>` | ``0.0`` |
  49. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  50. | :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` | :ref:`gravity_space_override<class_Area2D_property_gravity_space_override>` | ``0`` |
  51. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  52. | :ref:`float<class_float>` | :ref:`linear_damp<class_Area2D_property_linear_damp>` | ``0.1`` |
  53. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  54. | :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` | :ref:`linear_damp_space_override<class_Area2D_property_linear_damp_space_override>` | ``0`` |
  55. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  56. | :ref:`bool<class_bool>` | :ref:`monitorable<class_Area2D_property_monitorable>` | ``true`` |
  57. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  58. | :ref:`bool<class_bool>` | :ref:`monitoring<class_Area2D_property_monitoring>` | ``true`` |
  59. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  60. | :ref:`int<class_int>` | :ref:`priority<class_Area2D_property_priority>` | ``0`` |
  61. +-------------------------------------------------+---------------------------------------------------------------------------------------+-------------------+
  62. .. rst-class:: classref-reftable-group
  63. Methods
  64. -------
  65. .. table::
  66. :widths: auto
  67. +----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  68. | :ref:`Array<class_Array>`\[:ref:`Area2D<class_Area2D>`\] | :ref:`get_overlapping_areas<class_Area2D_method_get_overlapping_areas>`\ (\ ) |const| |
  69. +----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  70. | :ref:`Array<class_Array>`\[:ref:`Node2D<class_Node2D>`\] | :ref:`get_overlapping_bodies<class_Area2D_method_get_overlapping_bodies>`\ (\ ) |const| |
  71. +----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`has_overlapping_areas<class_Area2D_method_has_overlapping_areas>`\ (\ ) |const| |
  73. +----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  74. | :ref:`bool<class_bool>` | :ref:`has_overlapping_bodies<class_Area2D_method_has_overlapping_bodies>`\ (\ ) |const| |
  75. +----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  76. | :ref:`bool<class_bool>` | :ref:`overlaps_area<class_Area2D_method_overlaps_area>`\ (\ area\: :ref:`Node<class_Node>`\ ) |const| |
  77. +----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  78. | :ref:`bool<class_bool>` | :ref:`overlaps_body<class_Area2D_method_overlaps_body>`\ (\ body\: :ref:`Node<class_Node>`\ ) |const| |
  79. +----------------------------------------------------------+-------------------------------------------------------------------------------------------------------+
  80. .. rst-class:: classref-section-separator
  81. ----
  82. .. rst-class:: classref-descriptions-group
  83. Signals
  84. -------
  85. .. _class_Area2D_signal_area_entered:
  86. .. rst-class:: classref-signal
  87. **area_entered**\ (\ area\: :ref:`Area2D<class_Area2D>`\ ) :ref:`🔗<class_Area2D_signal_area_entered>`
  88. Emitted when the received ``area`` enters this area. Requires :ref:`monitoring<class_Area2D_property_monitoring>` to be set to ``true``.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _class_Area2D_signal_area_exited:
  92. .. rst-class:: classref-signal
  93. **area_exited**\ (\ area\: :ref:`Area2D<class_Area2D>`\ ) :ref:`🔗<class_Area2D_signal_area_exited>`
  94. Emitted when the received ``area`` exits this area. Requires :ref:`monitoring<class_Area2D_property_monitoring>` to be set to ``true``.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_Area2D_signal_area_shape_entered:
  98. .. rst-class:: classref-signal
  99. **area_shape_entered**\ (\ area_rid\: :ref:`RID<class_RID>`, area\: :ref:`Area2D<class_Area2D>`, area_shape_index\: :ref:`int<class_int>`, local_shape_index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Area2D_signal_area_shape_entered>`
  100. Emitted when a :ref:`Shape2D<class_Shape2D>` of the received ``area`` enters a shape of this area. Requires :ref:`monitoring<class_Area2D_property_monitoring>` to be set to ``true``.
  101. \ ``local_shape_index`` and ``area_shape_index`` contain indices of the interacting shapes from this area and the other area, respectively. ``area_rid`` contains the :ref:`RID<class_RID>` of the other area. These values can be used with the :ref:`PhysicsServer2D<class_PhysicsServer2D>`.
  102. \ **Example:** Get the :ref:`CollisionShape2D<class_CollisionShape2D>` node from the shape index:
  103. .. tabs::
  104. .. code-tab:: gdscript
  105. var other_shape_owner = area.shape_find_owner(area_shape_index)
  106. var other_shape_node = area.shape_owner_get_owner(other_shape_owner)
  107. var local_shape_owner = shape_find_owner(local_shape_index)
  108. var local_shape_node = shape_owner_get_owner(local_shape_owner)
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_Area2D_signal_area_shape_exited:
  112. .. rst-class:: classref-signal
  113. **area_shape_exited**\ (\ area_rid\: :ref:`RID<class_RID>`, area\: :ref:`Area2D<class_Area2D>`, area_shape_index\: :ref:`int<class_int>`, local_shape_index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Area2D_signal_area_shape_exited>`
  114. Emitted when a :ref:`Shape2D<class_Shape2D>` of the received ``area`` exits a shape of this area. Requires :ref:`monitoring<class_Area2D_property_monitoring>` to be set to ``true``.
  115. See also :ref:`area_shape_entered<class_Area2D_signal_area_shape_entered>`.
  116. .. rst-class:: classref-item-separator
  117. ----
  118. .. _class_Area2D_signal_body_entered:
  119. .. rst-class:: classref-signal
  120. **body_entered**\ (\ body\: :ref:`Node2D<class_Node2D>`\ ) :ref:`🔗<class_Area2D_signal_body_entered>`
  121. Emitted when the received ``body`` enters this area. ``body`` can be a :ref:`PhysicsBody2D<class_PhysicsBody2D>` or a :ref:`TileMap<class_TileMap>`. :ref:`TileMap<class_TileMap>`\ s are detected if their :ref:`TileSet<class_TileSet>` has collision shapes configured. Requires :ref:`monitoring<class_Area2D_property_monitoring>` to be set to ``true``.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_Area2D_signal_body_exited:
  125. .. rst-class:: classref-signal
  126. **body_exited**\ (\ body\: :ref:`Node2D<class_Node2D>`\ ) :ref:`🔗<class_Area2D_signal_body_exited>`
  127. Emitted when the received ``body`` exits this area. ``body`` can be a :ref:`PhysicsBody2D<class_PhysicsBody2D>` or a :ref:`TileMap<class_TileMap>`. :ref:`TileMap<class_TileMap>`\ s are detected if their :ref:`TileSet<class_TileSet>` has collision shapes configured. Requires :ref:`monitoring<class_Area2D_property_monitoring>` to be set to ``true``.
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _class_Area2D_signal_body_shape_entered:
  131. .. rst-class:: classref-signal
  132. **body_shape_entered**\ (\ body_rid\: :ref:`RID<class_RID>`, body\: :ref:`Node2D<class_Node2D>`, body_shape_index\: :ref:`int<class_int>`, local_shape_index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Area2D_signal_body_shape_entered>`
  133. Emitted when a :ref:`Shape2D<class_Shape2D>` of the received ``body`` enters a shape of this area. ``body`` can be a :ref:`PhysicsBody2D<class_PhysicsBody2D>` or a :ref:`TileMap<class_TileMap>`. :ref:`TileMap<class_TileMap>`\ s are detected if their :ref:`TileSet<class_TileSet>` has collision shapes configured. Requires :ref:`monitoring<class_Area2D_property_monitoring>` to be set to ``true``.
  134. \ ``local_shape_index`` and ``body_shape_index`` contain indices of the interacting shapes from this area and the interacting body, respectively. ``body_rid`` contains the :ref:`RID<class_RID>` of the body. These values can be used with the :ref:`PhysicsServer2D<class_PhysicsServer2D>`.
  135. \ **Example:** Get the :ref:`CollisionShape2D<class_CollisionShape2D>` node from the shape index:
  136. .. tabs::
  137. .. code-tab:: gdscript
  138. var body_shape_owner = body.shape_find_owner(body_shape_index)
  139. var body_shape_node = body.shape_owner_get_owner(body_shape_owner)
  140. var local_shape_owner = shape_find_owner(local_shape_index)
  141. var local_shape_node = shape_owner_get_owner(local_shape_owner)
  142. .. rst-class:: classref-item-separator
  143. ----
  144. .. _class_Area2D_signal_body_shape_exited:
  145. .. rst-class:: classref-signal
  146. **body_shape_exited**\ (\ body_rid\: :ref:`RID<class_RID>`, body\: :ref:`Node2D<class_Node2D>`, body_shape_index\: :ref:`int<class_int>`, local_shape_index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Area2D_signal_body_shape_exited>`
  147. Emitted when a :ref:`Shape2D<class_Shape2D>` of the received ``body`` exits a shape of this area. ``body`` can be a :ref:`PhysicsBody2D<class_PhysicsBody2D>` or a :ref:`TileMap<class_TileMap>`. :ref:`TileMap<class_TileMap>`\ s are detected if their :ref:`TileSet<class_TileSet>` has collision shapes configured. Requires :ref:`monitoring<class_Area2D_property_monitoring>` to be set to ``true``.
  148. See also :ref:`body_shape_entered<class_Area2D_signal_body_shape_entered>`.
  149. .. rst-class:: classref-section-separator
  150. ----
  151. .. rst-class:: classref-descriptions-group
  152. Enumerations
  153. ------------
  154. .. _enum_Area2D_SpaceOverride:
  155. .. rst-class:: classref-enumeration
  156. enum **SpaceOverride**: :ref:`🔗<enum_Area2D_SpaceOverride>`
  157. .. _class_Area2D_constant_SPACE_OVERRIDE_DISABLED:
  158. .. rst-class:: classref-enumeration-constant
  159. :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **SPACE_OVERRIDE_DISABLED** = ``0``
  160. This area does not affect gravity/damping.
  161. .. _class_Area2D_constant_SPACE_OVERRIDE_COMBINE:
  162. .. rst-class:: classref-enumeration-constant
  163. :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **SPACE_OVERRIDE_COMBINE** = ``1``
  164. This area adds its gravity/damping values to whatever has been calculated so far (in :ref:`priority<class_Area2D_property_priority>` order).
  165. .. _class_Area2D_constant_SPACE_OVERRIDE_COMBINE_REPLACE:
  166. .. rst-class:: classref-enumeration-constant
  167. :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **SPACE_OVERRIDE_COMBINE_REPLACE** = ``2``
  168. This area adds its gravity/damping values to whatever has been calculated so far (in :ref:`priority<class_Area2D_property_priority>` order), ignoring any lower priority areas.
  169. .. _class_Area2D_constant_SPACE_OVERRIDE_REPLACE:
  170. .. rst-class:: classref-enumeration-constant
  171. :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **SPACE_OVERRIDE_REPLACE** = ``3``
  172. This area replaces any gravity/damping, even the defaults, ignoring any lower priority areas.
  173. .. _class_Area2D_constant_SPACE_OVERRIDE_REPLACE_COMBINE:
  174. .. rst-class:: classref-enumeration-constant
  175. :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **SPACE_OVERRIDE_REPLACE_COMBINE** = ``4``
  176. This area replaces any gravity/damping calculated so far (in :ref:`priority<class_Area2D_property_priority>` order), but keeps calculating the rest of the areas.
  177. .. rst-class:: classref-section-separator
  178. ----
  179. .. rst-class:: classref-descriptions-group
  180. Property Descriptions
  181. ---------------------
  182. .. _class_Area2D_property_angular_damp:
  183. .. rst-class:: classref-property
  184. :ref:`float<class_float>` **angular_damp** = ``1.0`` :ref:`🔗<class_Area2D_property_angular_damp>`
  185. .. rst-class:: classref-property-setget
  186. - |void| **set_angular_damp**\ (\ value\: :ref:`float<class_float>`\ )
  187. - :ref:`float<class_float>` **get_angular_damp**\ (\ )
  188. The rate at which objects stop spinning in this area. Represents the angular velocity lost per second.
  189. See :ref:`ProjectSettings.physics/2d/default_angular_damp<class_ProjectSettings_property_physics/2d/default_angular_damp>` for more details about damping.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_Area2D_property_angular_damp_space_override:
  193. .. rst-class:: classref-property
  194. :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **angular_damp_space_override** = ``0`` :ref:`🔗<class_Area2D_property_angular_damp_space_override>`
  195. .. rst-class:: classref-property-setget
  196. - |void| **set_angular_damp_space_override_mode**\ (\ value\: :ref:`SpaceOverride<enum_Area2D_SpaceOverride>`\ )
  197. - :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **get_angular_damp_space_override_mode**\ (\ )
  198. Override mode for angular damping calculations within this area. See :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` for possible values.
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_Area2D_property_audio_bus_name:
  202. .. rst-class:: classref-property
  203. :ref:`StringName<class_StringName>` **audio_bus_name** = ``&"Master"`` :ref:`🔗<class_Area2D_property_audio_bus_name>`
  204. .. rst-class:: classref-property-setget
  205. - |void| **set_audio_bus_name**\ (\ value\: :ref:`StringName<class_StringName>`\ )
  206. - :ref:`StringName<class_StringName>` **get_audio_bus_name**\ (\ )
  207. The name of the area's audio bus.
  208. .. rst-class:: classref-item-separator
  209. ----
  210. .. _class_Area2D_property_audio_bus_override:
  211. .. rst-class:: classref-property
  212. :ref:`bool<class_bool>` **audio_bus_override** = ``false`` :ref:`🔗<class_Area2D_property_audio_bus_override>`
  213. .. rst-class:: classref-property-setget
  214. - |void| **set_audio_bus_override**\ (\ value\: :ref:`bool<class_bool>`\ )
  215. - :ref:`bool<class_bool>` **is_overriding_audio_bus**\ (\ )
  216. If ``true``, the area's audio bus overrides the default audio bus.
  217. .. rst-class:: classref-item-separator
  218. ----
  219. .. _class_Area2D_property_gravity:
  220. .. rst-class:: classref-property
  221. :ref:`float<class_float>` **gravity** = ``980.0`` :ref:`🔗<class_Area2D_property_gravity>`
  222. .. rst-class:: classref-property-setget
  223. - |void| **set_gravity**\ (\ value\: :ref:`float<class_float>`\ )
  224. - :ref:`float<class_float>` **get_gravity**\ (\ )
  225. The area's gravity intensity (in pixels per second squared). This value multiplies the gravity direction. This is useful to alter the force of gravity without altering its direction.
  226. .. rst-class:: classref-item-separator
  227. ----
  228. .. _class_Area2D_property_gravity_direction:
  229. .. rst-class:: classref-property
  230. :ref:`Vector2<class_Vector2>` **gravity_direction** = ``Vector2(0, 1)`` :ref:`🔗<class_Area2D_property_gravity_direction>`
  231. .. rst-class:: classref-property-setget
  232. - |void| **set_gravity_direction**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  233. - :ref:`Vector2<class_Vector2>` **get_gravity_direction**\ (\ )
  234. The area's gravity vector (not normalized).
  235. .. rst-class:: classref-item-separator
  236. ----
  237. .. _class_Area2D_property_gravity_point:
  238. .. rst-class:: classref-property
  239. :ref:`bool<class_bool>` **gravity_point** = ``false`` :ref:`🔗<class_Area2D_property_gravity_point>`
  240. .. rst-class:: classref-property-setget
  241. - |void| **set_gravity_is_point**\ (\ value\: :ref:`bool<class_bool>`\ )
  242. - :ref:`bool<class_bool>` **is_gravity_a_point**\ (\ )
  243. If ``true``, gravity is calculated from a point (set via :ref:`gravity_point_center<class_Area2D_property_gravity_point_center>`). See also :ref:`gravity_space_override<class_Area2D_property_gravity_space_override>`.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_Area2D_property_gravity_point_center:
  247. .. rst-class:: classref-property
  248. :ref:`Vector2<class_Vector2>` **gravity_point_center** = ``Vector2(0, 1)`` :ref:`🔗<class_Area2D_property_gravity_point_center>`
  249. .. rst-class:: classref-property-setget
  250. - |void| **set_gravity_point_center**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  251. - :ref:`Vector2<class_Vector2>` **get_gravity_point_center**\ (\ )
  252. If gravity is a point (see :ref:`gravity_point<class_Area2D_property_gravity_point>`), this will be the point of attraction.
  253. .. rst-class:: classref-item-separator
  254. ----
  255. .. _class_Area2D_property_gravity_point_unit_distance:
  256. .. rst-class:: classref-property
  257. :ref:`float<class_float>` **gravity_point_unit_distance** = ``0.0`` :ref:`🔗<class_Area2D_property_gravity_point_unit_distance>`
  258. .. rst-class:: classref-property-setget
  259. - |void| **set_gravity_point_unit_distance**\ (\ value\: :ref:`float<class_float>`\ )
  260. - :ref:`float<class_float>` **get_gravity_point_unit_distance**\ (\ )
  261. The distance at which the gravity strength is equal to :ref:`gravity<class_Area2D_property_gravity>`. For example, on a planet 100 pixels in radius with a surface gravity of 4.0 px/s², set the :ref:`gravity<class_Area2D_property_gravity>` to 4.0 and the unit distance to 100.0. The gravity will have falloff according to the inverse square law, so in the example, at 200 pixels from the center the gravity will be 1.0 px/s² (twice the distance, 1/4th the gravity), at 50 pixels it will be 16.0 px/s² (half the distance, 4x the gravity), and so on.
  262. The above is true only when the unit distance is a positive number. When this is set to 0.0, the gravity will be constant regardless of distance.
  263. .. rst-class:: classref-item-separator
  264. ----
  265. .. _class_Area2D_property_gravity_space_override:
  266. .. rst-class:: classref-property
  267. :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **gravity_space_override** = ``0`` :ref:`🔗<class_Area2D_property_gravity_space_override>`
  268. .. rst-class:: classref-property-setget
  269. - |void| **set_gravity_space_override_mode**\ (\ value\: :ref:`SpaceOverride<enum_Area2D_SpaceOverride>`\ )
  270. - :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **get_gravity_space_override_mode**\ (\ )
  271. Override mode for gravity calculations within this area. See :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` for possible values.
  272. .. rst-class:: classref-item-separator
  273. ----
  274. .. _class_Area2D_property_linear_damp:
  275. .. rst-class:: classref-property
  276. :ref:`float<class_float>` **linear_damp** = ``0.1`` :ref:`🔗<class_Area2D_property_linear_damp>`
  277. .. rst-class:: classref-property-setget
  278. - |void| **set_linear_damp**\ (\ value\: :ref:`float<class_float>`\ )
  279. - :ref:`float<class_float>` **get_linear_damp**\ (\ )
  280. The rate at which objects stop moving in this area. Represents the linear velocity lost per second.
  281. See :ref:`ProjectSettings.physics/2d/default_linear_damp<class_ProjectSettings_property_physics/2d/default_linear_damp>` for more details about damping.
  282. .. rst-class:: classref-item-separator
  283. ----
  284. .. _class_Area2D_property_linear_damp_space_override:
  285. .. rst-class:: classref-property
  286. :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **linear_damp_space_override** = ``0`` :ref:`🔗<class_Area2D_property_linear_damp_space_override>`
  287. .. rst-class:: classref-property-setget
  288. - |void| **set_linear_damp_space_override_mode**\ (\ value\: :ref:`SpaceOverride<enum_Area2D_SpaceOverride>`\ )
  289. - :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` **get_linear_damp_space_override_mode**\ (\ )
  290. Override mode for linear damping calculations within this area. See :ref:`SpaceOverride<enum_Area2D_SpaceOverride>` for possible values.
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_Area2D_property_monitorable:
  294. .. rst-class:: classref-property
  295. :ref:`bool<class_bool>` **monitorable** = ``true`` :ref:`🔗<class_Area2D_property_monitorable>`
  296. .. rst-class:: classref-property-setget
  297. - |void| **set_monitorable**\ (\ value\: :ref:`bool<class_bool>`\ )
  298. - :ref:`bool<class_bool>` **is_monitorable**\ (\ )
  299. If ``true``, other monitoring areas can detect this area.
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _class_Area2D_property_monitoring:
  303. .. rst-class:: classref-property
  304. :ref:`bool<class_bool>` **monitoring** = ``true`` :ref:`🔗<class_Area2D_property_monitoring>`
  305. .. rst-class:: classref-property-setget
  306. - |void| **set_monitoring**\ (\ value\: :ref:`bool<class_bool>`\ )
  307. - :ref:`bool<class_bool>` **is_monitoring**\ (\ )
  308. If ``true``, the area detects bodies or areas entering and exiting it.
  309. .. rst-class:: classref-item-separator
  310. ----
  311. .. _class_Area2D_property_priority:
  312. .. rst-class:: classref-property
  313. :ref:`int<class_int>` **priority** = ``0`` :ref:`🔗<class_Area2D_property_priority>`
  314. .. rst-class:: classref-property-setget
  315. - |void| **set_priority**\ (\ value\: :ref:`int<class_int>`\ )
  316. - :ref:`int<class_int>` **get_priority**\ (\ )
  317. The area's priority. Higher priority areas are processed first. The :ref:`World2D<class_World2D>`'s physics is always processed last, after all areas.
  318. .. rst-class:: classref-section-separator
  319. ----
  320. .. rst-class:: classref-descriptions-group
  321. Method Descriptions
  322. -------------------
  323. .. _class_Area2D_method_get_overlapping_areas:
  324. .. rst-class:: classref-method
  325. :ref:`Array<class_Array>`\[:ref:`Area2D<class_Area2D>`\] **get_overlapping_areas**\ (\ ) |const| :ref:`🔗<class_Area2D_method_get_overlapping_areas>`
  326. Returns a list of intersecting **Area2D**\ s. The overlapping area's :ref:`CollisionObject2D.collision_layer<class_CollisionObject2D_property_collision_layer>` must be part of this area's :ref:`CollisionObject2D.collision_mask<class_CollisionObject2D_property_collision_mask>` in order to be detected.
  327. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
  328. .. rst-class:: classref-item-separator
  329. ----
  330. .. _class_Area2D_method_get_overlapping_bodies:
  331. .. rst-class:: classref-method
  332. :ref:`Array<class_Array>`\[:ref:`Node2D<class_Node2D>`\] **get_overlapping_bodies**\ (\ ) |const| :ref:`🔗<class_Area2D_method_get_overlapping_bodies>`
  333. Returns a list of intersecting :ref:`PhysicsBody2D<class_PhysicsBody2D>`\ s and :ref:`TileMap<class_TileMap>`\ s. The overlapping body's :ref:`CollisionObject2D.collision_layer<class_CollisionObject2D_property_collision_layer>` must be part of this area's :ref:`CollisionObject2D.collision_mask<class_CollisionObject2D_property_collision_mask>` in order to be detected.
  334. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
  335. .. rst-class:: classref-item-separator
  336. ----
  337. .. _class_Area2D_method_has_overlapping_areas:
  338. .. rst-class:: classref-method
  339. :ref:`bool<class_bool>` **has_overlapping_areas**\ (\ ) |const| :ref:`🔗<class_Area2D_method_has_overlapping_areas>`
  340. Returns ``true`` if intersecting any **Area2D**\ s, otherwise returns ``false``. The overlapping area's :ref:`CollisionObject2D.collision_layer<class_CollisionObject2D_property_collision_layer>` must be part of this area's :ref:`CollisionObject2D.collision_mask<class_CollisionObject2D_property_collision_mask>` in order to be detected.
  341. For performance reasons (collisions are all processed at the same time) the list of overlapping areas is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
  342. .. rst-class:: classref-item-separator
  343. ----
  344. .. _class_Area2D_method_has_overlapping_bodies:
  345. .. rst-class:: classref-method
  346. :ref:`bool<class_bool>` **has_overlapping_bodies**\ (\ ) |const| :ref:`🔗<class_Area2D_method_has_overlapping_bodies>`
  347. Returns ``true`` if intersecting any :ref:`PhysicsBody2D<class_PhysicsBody2D>`\ s or :ref:`TileMap<class_TileMap>`\ s, otherwise returns ``false``. The overlapping body's :ref:`CollisionObject2D.collision_layer<class_CollisionObject2D_property_collision_layer>` must be part of this area's :ref:`CollisionObject2D.collision_mask<class_CollisionObject2D_property_collision_mask>` in order to be detected.
  348. For performance reasons (collisions are all processed at the same time) the list of overlapping bodies is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_Area2D_method_overlaps_area:
  352. .. rst-class:: classref-method
  353. :ref:`bool<class_bool>` **overlaps_area**\ (\ area\: :ref:`Node<class_Node>`\ ) |const| :ref:`🔗<class_Area2D_method_overlaps_area>`
  354. Returns ``true`` if the given **Area2D** intersects or overlaps this **Area2D**, ``false`` otherwise.
  355. \ **Note:** The result of this test is not immediate after moving objects. For performance, the list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_Area2D_method_overlaps_body:
  359. .. rst-class:: classref-method
  360. :ref:`bool<class_bool>` **overlaps_body**\ (\ body\: :ref:`Node<class_Node>`\ ) |const| :ref:`🔗<class_Area2D_method_overlaps_body>`
  361. Returns ``true`` if the given physics body intersects or overlaps this **Area2D**, ``false`` otherwise.
  362. \ **Note:** The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
  363. The ``body`` argument can either be a :ref:`PhysicsBody2D<class_PhysicsBody2D>` or a :ref:`TileMap<class_TileMap>` instance. While TileMaps are not physics bodies themselves, they register their tiles with collision shapes as a virtual physics body.
  364. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  365. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  366. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  367. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  368. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  369. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  370. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  371. .. |void| replace:: :abbr:`void (No return value.)`