CollisionObject2D.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="CollisionObject2D" inherits="Node2D" version="3.4">
  3. <brief_description>
  4. Base node for 2D collision objects.
  5. </brief_description>
  6. <description>
  7. CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision [Shape2D]s. Each shape must be assigned to a [i]shape owner[/i]. The CollisionObject2D 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 [code]shape_owner_*[/code] methods.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="_input_event" qualifiers="virtual">
  13. <return type="void">
  14. </return>
  15. <argument index="0" name="viewport" type="Object">
  16. </argument>
  17. <argument index="1" name="event" type="InputEvent">
  18. </argument>
  19. <argument index="2" name="shape_idx" type="int">
  20. </argument>
  21. <description>
  22. Accepts unhandled [InputEvent]s. Requires [member input_pickable] to be [code]true[/code]. [code]shape_idx[/code] is the child index of the clicked [Shape2D]. Connect to the [code]input_event[/code] signal to easily pick up these events.
  23. </description>
  24. </method>
  25. <method name="create_shape_owner">
  26. <return type="int">
  27. </return>
  28. <argument index="0" name="owner" type="Object">
  29. </argument>
  30. <description>
  31. Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
  32. </description>
  33. </method>
  34. <method name="get_collision_layer_bit" qualifiers="const">
  35. <return type="bool">
  36. </return>
  37. <argument index="0" name="bit" type="int">
  38. </argument>
  39. <description>
  40. Returns whether or not the specified [code]bit[/code] of the [member collision_layer] is set.
  41. </description>
  42. </method>
  43. <method name="get_collision_mask_bit" qualifiers="const">
  44. <return type="bool">
  45. </return>
  46. <argument index="0" name="bit" type="int">
  47. </argument>
  48. <description>
  49. Returns whether or not the specified [code]bit[/code] of the [member collision_mask] is set.
  50. </description>
  51. </method>
  52. <method name="get_rid" qualifiers="const">
  53. <return type="RID">
  54. </return>
  55. <description>
  56. Returns the object's [RID].
  57. </description>
  58. </method>
  59. <method name="get_shape_owner_one_way_collision_margin" qualifiers="const">
  60. <return type="float">
  61. </return>
  62. <argument index="0" name="owner_id" type="int">
  63. </argument>
  64. <description>
  65. Returns the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code].
  66. </description>
  67. </method>
  68. <method name="get_shape_owners">
  69. <return type="Array">
  70. </return>
  71. <description>
  72. Returns an [Array] of [code]owner_id[/code] identifiers. You can use these ids in other methods that take [code]owner_id[/code] as an argument.
  73. </description>
  74. </method>
  75. <method name="is_shape_owner_disabled" qualifiers="const">
  76. <return type="bool">
  77. </return>
  78. <argument index="0" name="owner_id" type="int">
  79. </argument>
  80. <description>
  81. If [code]true[/code], the shape owner and its shapes are disabled.
  82. </description>
  83. </method>
  84. <method name="is_shape_owner_one_way_collision_enabled" qualifiers="const">
  85. <return type="bool">
  86. </return>
  87. <argument index="0" name="owner_id" type="int">
  88. </argument>
  89. <description>
  90. Returns [code]true[/code] if collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
  91. </description>
  92. </method>
  93. <method name="remove_shape_owner">
  94. <return type="void">
  95. </return>
  96. <argument index="0" name="owner_id" type="int">
  97. </argument>
  98. <description>
  99. Removes the given shape owner.
  100. </description>
  101. </method>
  102. <method name="set_collision_layer_bit">
  103. <return type="void">
  104. </return>
  105. <argument index="0" name="bit" type="int">
  106. </argument>
  107. <argument index="1" name="value" type="bool">
  108. </argument>
  109. <description>
  110. If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_layer].
  111. If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_layer].
  112. </description>
  113. </method>
  114. <method name="set_collision_mask_bit">
  115. <return type="void">
  116. </return>
  117. <argument index="0" name="bit" type="int">
  118. </argument>
  119. <argument index="1" name="value" type="bool">
  120. </argument>
  121. <description>
  122. If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_mask].
  123. If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_mask].
  124. </description>
  125. </method>
  126. <method name="shape_find_owner" qualifiers="const">
  127. <return type="int">
  128. </return>
  129. <argument index="0" name="shape_index" type="int">
  130. </argument>
  131. <description>
  132. Returns the [code]owner_id[/code] of the given shape.
  133. </description>
  134. </method>
  135. <method name="shape_owner_add_shape">
  136. <return type="void">
  137. </return>
  138. <argument index="0" name="owner_id" type="int">
  139. </argument>
  140. <argument index="1" name="shape" type="Shape2D">
  141. </argument>
  142. <description>
  143. Adds a [Shape2D] to the shape owner.
  144. </description>
  145. </method>
  146. <method name="shape_owner_clear_shapes">
  147. <return type="void">
  148. </return>
  149. <argument index="0" name="owner_id" type="int">
  150. </argument>
  151. <description>
  152. Removes all shapes from the shape owner.
  153. </description>
  154. </method>
  155. <method name="shape_owner_get_owner" qualifiers="const">
  156. <return type="Object">
  157. </return>
  158. <argument index="0" name="owner_id" type="int">
  159. </argument>
  160. <description>
  161. Returns the parent object of the given shape owner.
  162. </description>
  163. </method>
  164. <method name="shape_owner_get_shape" qualifiers="const">
  165. <return type="Shape2D">
  166. </return>
  167. <argument index="0" name="owner_id" type="int">
  168. </argument>
  169. <argument index="1" name="shape_id" type="int">
  170. </argument>
  171. <description>
  172. Returns the [Shape2D] with the given id from the given shape owner.
  173. </description>
  174. </method>
  175. <method name="shape_owner_get_shape_count" qualifiers="const">
  176. <return type="int">
  177. </return>
  178. <argument index="0" name="owner_id" type="int">
  179. </argument>
  180. <description>
  181. Returns the number of shapes the given shape owner contains.
  182. </description>
  183. </method>
  184. <method name="shape_owner_get_shape_index" qualifiers="const">
  185. <return type="int">
  186. </return>
  187. <argument index="0" name="owner_id" type="int">
  188. </argument>
  189. <argument index="1" name="shape_id" type="int">
  190. </argument>
  191. <description>
  192. Returns the child index of the [Shape2D] with the given id from the given shape owner.
  193. </description>
  194. </method>
  195. <method name="shape_owner_get_transform" qualifiers="const">
  196. <return type="Transform2D">
  197. </return>
  198. <argument index="0" name="owner_id" type="int">
  199. </argument>
  200. <description>
  201. Returns the shape owner's [Transform2D].
  202. </description>
  203. </method>
  204. <method name="shape_owner_remove_shape">
  205. <return type="void">
  206. </return>
  207. <argument index="0" name="owner_id" type="int">
  208. </argument>
  209. <argument index="1" name="shape_id" type="int">
  210. </argument>
  211. <description>
  212. Removes a shape from the given shape owner.
  213. </description>
  214. </method>
  215. <method name="shape_owner_set_disabled">
  216. <return type="void">
  217. </return>
  218. <argument index="0" name="owner_id" type="int">
  219. </argument>
  220. <argument index="1" name="disabled" type="bool">
  221. </argument>
  222. <description>
  223. If [code]true[/code], disables the given shape owner.
  224. </description>
  225. </method>
  226. <method name="shape_owner_set_one_way_collision">
  227. <return type="void">
  228. </return>
  229. <argument index="0" name="owner_id" type="int">
  230. </argument>
  231. <argument index="1" name="enable" type="bool">
  232. </argument>
  233. <description>
  234. If [code]enable[/code] is [code]true[/code], collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
  235. </description>
  236. </method>
  237. <method name="shape_owner_set_one_way_collision_margin">
  238. <return type="void">
  239. </return>
  240. <argument index="0" name="owner_id" type="int">
  241. </argument>
  242. <argument index="1" name="margin" type="float">
  243. </argument>
  244. <description>
  245. Sets the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code] to [code]margin[/code] pixels.
  246. </description>
  247. </method>
  248. <method name="shape_owner_set_transform">
  249. <return type="void">
  250. </return>
  251. <argument index="0" name="owner_id" type="int">
  252. </argument>
  253. <argument index="1" name="transform" type="Transform2D">
  254. </argument>
  255. <description>
  256. Sets the [Transform2D] of the given shape owner.
  257. </description>
  258. </method>
  259. </methods>
  260. <members>
  261. <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
  262. The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask].
  263. [b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
  264. </member>
  265. <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
  266. The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also [member collision_layer].
  267. [b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
  268. </member>
  269. <member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" default="true">
  270. If [code]true[/code], this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one [code]collision_layer[/code] bit to be set.
  271. </member>
  272. </members>
  273. <signals>
  274. <signal name="input_event">
  275. <argument index="0" name="viewport" type="Node">
  276. </argument>
  277. <argument index="1" name="event" type="InputEvent">
  278. </argument>
  279. <argument index="2" name="shape_idx" type="int">
  280. </argument>
  281. <description>
  282. Emitted when an input event occurs. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set. See [method _input_event] for details.
  283. </description>
  284. </signal>
  285. <signal name="mouse_entered">
  286. <description>
  287. Emitted when the mouse pointer enters any of this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
  288. </description>
  289. </signal>
  290. <signal name="mouse_exited">
  291. <description>
  292. Emitted when the mouse pointer exits all this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
  293. </description>
  294. </signal>
  295. </signals>
  296. <constants>
  297. </constants>
  298. </class>