PhysicsServer2D.xml 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="PhysicsServer2D" inherits="Object" version="4.0">
  3. <brief_description>
  4. Server interface for low-level 2D physics access.
  5. </brief_description>
  6. <description>
  7. PhysicsServer2D is the server responsible for all 2D physics. It can create many kinds of physics objects, but does not insert them on the node tree.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="area_add_shape">
  13. <return type="void" />
  14. <argument index="0" name="area" type="RID" />
  15. <argument index="1" name="shape" type="RID" />
  16. <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)" />
  17. <argument index="3" name="disabled" type="bool" default="false" />
  18. <description>
  19. Adds a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.
  20. </description>
  21. </method>
  22. <method name="area_attach_canvas_instance_id">
  23. <return type="void" />
  24. <argument index="0" name="area" type="RID" />
  25. <argument index="1" name="id" type="int" />
  26. <description>
  27. </description>
  28. </method>
  29. <method name="area_attach_object_instance_id">
  30. <return type="void" />
  31. <argument index="0" name="area" type="RID" />
  32. <argument index="1" name="id" type="int" />
  33. <description>
  34. Assigns the area to a descendant of [Object], so it can exist in the node tree.
  35. </description>
  36. </method>
  37. <method name="area_clear_shapes">
  38. <return type="void" />
  39. <argument index="0" name="area" type="RID" />
  40. <description>
  41. Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.
  42. </description>
  43. </method>
  44. <method name="area_create">
  45. <return type="RID" />
  46. <description>
  47. Creates an [Area2D]. After creating an [Area2D] with this method, assign it to a space using [method area_set_space] to use the created [Area2D] in the physics world.
  48. </description>
  49. </method>
  50. <method name="area_get_canvas_instance_id" qualifiers="const">
  51. <return type="int" />
  52. <argument index="0" name="area" type="RID" />
  53. <description>
  54. </description>
  55. </method>
  56. <method name="area_get_object_instance_id" qualifiers="const">
  57. <return type="int" />
  58. <argument index="0" name="area" type="RID" />
  59. <description>
  60. Gets the instance ID of the object the area is assigned to.
  61. </description>
  62. </method>
  63. <method name="area_get_param" qualifiers="const">
  64. <return type="Variant" />
  65. <argument index="0" name="area" type="RID" />
  66. <argument index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter" />
  67. <description>
  68. Returns an area parameter value. See [enum AreaParameter] for a list of available parameters.
  69. </description>
  70. </method>
  71. <method name="area_get_shape" qualifiers="const">
  72. <return type="RID" />
  73. <argument index="0" name="area" type="RID" />
  74. <argument index="1" name="shape_idx" type="int" />
  75. <description>
  76. Returns the [RID] of the nth shape of an area.
  77. </description>
  78. </method>
  79. <method name="area_get_shape_count" qualifiers="const">
  80. <return type="int" />
  81. <argument index="0" name="area" type="RID" />
  82. <description>
  83. Returns the number of shapes assigned to an area.
  84. </description>
  85. </method>
  86. <method name="area_get_shape_transform" qualifiers="const">
  87. <return type="Transform2D" />
  88. <argument index="0" name="area" type="RID" />
  89. <argument index="1" name="shape_idx" type="int" />
  90. <description>
  91. Returns the transform matrix of a shape within an area.
  92. </description>
  93. </method>
  94. <method name="area_get_space" qualifiers="const">
  95. <return type="RID" />
  96. <argument index="0" name="area" type="RID" />
  97. <description>
  98. Returns the space assigned to the area.
  99. </description>
  100. </method>
  101. <method name="area_get_space_override_mode" qualifiers="const">
  102. <return type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode" />
  103. <argument index="0" name="area" type="RID" />
  104. <description>
  105. Returns the space override mode for the area.
  106. </description>
  107. </method>
  108. <method name="area_get_transform" qualifiers="const">
  109. <return type="Transform2D" />
  110. <argument index="0" name="area" type="RID" />
  111. <description>
  112. Returns the transform matrix for an area.
  113. </description>
  114. </method>
  115. <method name="area_remove_shape">
  116. <return type="void" />
  117. <argument index="0" name="area" type="RID" />
  118. <argument index="1" name="shape_idx" type="int" />
  119. <description>
  120. Removes a shape from an area. It does not delete the shape, so it can be reassigned later.
  121. </description>
  122. </method>
  123. <method name="area_set_area_monitor_callback">
  124. <return type="void" />
  125. <argument index="0" name="area" type="RID" />
  126. <argument index="1" name="callback" type="Callable" />
  127. <description>
  128. </description>
  129. </method>
  130. <method name="area_set_collision_layer">
  131. <return type="void" />
  132. <argument index="0" name="area" type="RID" />
  133. <argument index="1" name="layer" type="int" />
  134. <description>
  135. Assigns the area to one or many physics layers.
  136. </description>
  137. </method>
  138. <method name="area_set_collision_mask">
  139. <return type="void" />
  140. <argument index="0" name="area" type="RID" />
  141. <argument index="1" name="mask" type="int" />
  142. <description>
  143. Sets which physics layers the area will monitor.
  144. </description>
  145. </method>
  146. <method name="area_set_monitor_callback">
  147. <return type="void" />
  148. <argument index="0" name="area" type="RID" />
  149. <argument index="1" name="callback" type="Callable" />
  150. <description>
  151. Sets the function to call when any body/area enters or exits the area. This callback will be called for any object interacting with the area, and takes five parameters:
  152. 1: [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED], depending on whether the object entered or exited the area.
  153. 2: [RID] of the object that entered/exited the area.
  154. 3: Instance ID of the object that entered/exited the area.
  155. 4: The shape index of the object that entered/exited the area.
  156. 5: The shape index of the area where the object entered/exited.
  157. </description>
  158. </method>
  159. <method name="area_set_monitorable">
  160. <return type="void" />
  161. <argument index="0" name="area" type="RID" />
  162. <argument index="1" name="monitorable" type="bool" />
  163. <description>
  164. </description>
  165. </method>
  166. <method name="area_set_param">
  167. <return type="void" />
  168. <argument index="0" name="area" type="RID" />
  169. <argument index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter" />
  170. <argument index="2" name="value" type="Variant" />
  171. <description>
  172. Sets the value for an area parameter. See [enum AreaParameter] for a list of available parameters.
  173. </description>
  174. </method>
  175. <method name="area_set_shape">
  176. <return type="void" />
  177. <argument index="0" name="area" type="RID" />
  178. <argument index="1" name="shape_idx" type="int" />
  179. <argument index="2" name="shape" type="RID" />
  180. <description>
  181. Substitutes a given area shape by another. The old shape is selected by its index, the new one by its [RID].
  182. </description>
  183. </method>
  184. <method name="area_set_shape_disabled">
  185. <return type="void" />
  186. <argument index="0" name="area" type="RID" />
  187. <argument index="1" name="shape_idx" type="int" />
  188. <argument index="2" name="disabled" type="bool" />
  189. <description>
  190. Disables a given shape in an area.
  191. </description>
  192. </method>
  193. <method name="area_set_shape_transform">
  194. <return type="void" />
  195. <argument index="0" name="area" type="RID" />
  196. <argument index="1" name="shape_idx" type="int" />
  197. <argument index="2" name="transform" type="Transform2D" />
  198. <description>
  199. Sets the transform matrix for an area shape.
  200. </description>
  201. </method>
  202. <method name="area_set_space">
  203. <return type="void" />
  204. <argument index="0" name="area" type="RID" />
  205. <argument index="1" name="space" type="RID" />
  206. <description>
  207. Assigns a space to the area.
  208. </description>
  209. </method>
  210. <method name="area_set_space_override_mode">
  211. <return type="void" />
  212. <argument index="0" name="area" type="RID" />
  213. <argument index="1" name="mode" type="int" enum="PhysicsServer2D.AreaSpaceOverrideMode" />
  214. <description>
  215. Sets the space override mode for the area. See [enum AreaSpaceOverrideMode] for a list of available modes.
  216. </description>
  217. </method>
  218. <method name="area_set_transform">
  219. <return type="void" />
  220. <argument index="0" name="area" type="RID" />
  221. <argument index="1" name="transform" type="Transform2D" />
  222. <description>
  223. Sets the transform matrix for an area.
  224. </description>
  225. </method>
  226. <method name="body_add_central_force">
  227. <return type="void" />
  228. <argument index="0" name="body" type="RID" />
  229. <argument index="1" name="force" type="Vector2" />
  230. <description>
  231. </description>
  232. </method>
  233. <method name="body_add_collision_exception">
  234. <return type="void" />
  235. <argument index="0" name="body" type="RID" />
  236. <argument index="1" name="excepted_body" type="RID" />
  237. <description>
  238. Adds a body to the list of bodies exempt from collisions.
  239. </description>
  240. </method>
  241. <method name="body_add_force">
  242. <return type="void" />
  243. <argument index="0" name="body" type="RID" />
  244. <argument index="1" name="force" type="Vector2" />
  245. <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)" />
  246. <description>
  247. Adds a positioned force to the applied force and torque. As with [method body_apply_impulse], both the force and the offset from the body origin are in global coordinates. A force differs from an impulse in that, while the two are forces, the impulse clears itself after being applied.
  248. </description>
  249. </method>
  250. <method name="body_add_shape">
  251. <return type="void" />
  252. <argument index="0" name="body" type="RID" />
  253. <argument index="1" name="shape" type="RID" />
  254. <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)" />
  255. <argument index="3" name="disabled" type="bool" default="false" />
  256. <description>
  257. Adds a shape to the body, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.
  258. </description>
  259. </method>
  260. <method name="body_add_torque">
  261. <return type="void" />
  262. <argument index="0" name="body" type="RID" />
  263. <argument index="1" name="torque" type="float" />
  264. <description>
  265. </description>
  266. </method>
  267. <method name="body_apply_central_impulse">
  268. <return type="void" />
  269. <argument index="0" name="body" type="RID" />
  270. <argument index="1" name="impulse" type="Vector2" />
  271. <description>
  272. </description>
  273. </method>
  274. <method name="body_apply_impulse">
  275. <return type="void" />
  276. <argument index="0" name="body" type="RID" />
  277. <argument index="1" name="impulse" type="Vector2" />
  278. <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)" />
  279. <description>
  280. Adds a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates.
  281. </description>
  282. </method>
  283. <method name="body_apply_torque_impulse">
  284. <return type="void" />
  285. <argument index="0" name="body" type="RID" />
  286. <argument index="1" name="impulse" type="float" />
  287. <description>
  288. </description>
  289. </method>
  290. <method name="body_attach_canvas_instance_id">
  291. <return type="void" />
  292. <argument index="0" name="body" type="RID" />
  293. <argument index="1" name="id" type="int" />
  294. <description>
  295. </description>
  296. </method>
  297. <method name="body_attach_object_instance_id">
  298. <return type="void" />
  299. <argument index="0" name="body" type="RID" />
  300. <argument index="1" name="id" type="int" />
  301. <description>
  302. Assigns the area to a descendant of [Object], so it can exist in the node tree.
  303. </description>
  304. </method>
  305. <method name="body_clear_shapes">
  306. <return type="void" />
  307. <argument index="0" name="body" type="RID" />
  308. <description>
  309. Removes all shapes from a body.
  310. </description>
  311. </method>
  312. <method name="body_create">
  313. <return type="RID" />
  314. <description>
  315. Creates a physics body.
  316. </description>
  317. </method>
  318. <method name="body_get_canvas_instance_id" qualifiers="const">
  319. <return type="int" />
  320. <argument index="0" name="body" type="RID" />
  321. <description>
  322. </description>
  323. </method>
  324. <method name="body_get_collision_layer" qualifiers="const">
  325. <return type="int" />
  326. <argument index="0" name="body" type="RID" />
  327. <description>
  328. Returns the physics layer or layers a body belongs to.
  329. </description>
  330. </method>
  331. <method name="body_get_collision_mask" qualifiers="const">
  332. <return type="int" />
  333. <argument index="0" name="body" type="RID" />
  334. <description>
  335. Returns the physics layer or layers a body can collide with.
  336. </description>
  337. </method>
  338. <method name="body_get_continuous_collision_detection_mode" qualifiers="const">
  339. <return type="int" enum="PhysicsServer2D.CCDMode" />
  340. <argument index="0" name="body" type="RID" />
  341. <description>
  342. Returns the continuous collision detection mode.
  343. </description>
  344. </method>
  345. <method name="body_get_direct_state">
  346. <return type="PhysicsDirectBodyState2D" />
  347. <argument index="0" name="body" type="RID" />
  348. <description>
  349. Returns the [PhysicsDirectBodyState2D] of the body.
  350. </description>
  351. </method>
  352. <method name="body_get_max_contacts_reported" qualifiers="const">
  353. <return type="int" />
  354. <argument index="0" name="body" type="RID" />
  355. <description>
  356. Returns the maximum contacts that can be reported. See [method body_set_max_contacts_reported].
  357. </description>
  358. </method>
  359. <method name="body_get_mode" qualifiers="const">
  360. <return type="int" enum="PhysicsServer2D.BodyMode" />
  361. <argument index="0" name="body" type="RID" />
  362. <description>
  363. Returns the body mode.
  364. </description>
  365. </method>
  366. <method name="body_get_object_instance_id" qualifiers="const">
  367. <return type="int" />
  368. <argument index="0" name="body" type="RID" />
  369. <description>
  370. Gets the instance ID of the object the area is assigned to.
  371. </description>
  372. </method>
  373. <method name="body_get_param" qualifiers="const">
  374. <return type="Variant" />
  375. <argument index="0" name="body" type="RID" />
  376. <argument index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter" />
  377. <description>
  378. Returns the value of a body parameter. See [enum BodyParameter] for a list of available parameters.
  379. </description>
  380. </method>
  381. <method name="body_get_shape" qualifiers="const">
  382. <return type="RID" />
  383. <argument index="0" name="body" type="RID" />
  384. <argument index="1" name="shape_idx" type="int" />
  385. <description>
  386. Returns the [RID] of the nth shape of a body.
  387. </description>
  388. </method>
  389. <method name="body_get_shape_count" qualifiers="const">
  390. <return type="int" />
  391. <argument index="0" name="body" type="RID" />
  392. <description>
  393. Returns the number of shapes assigned to a body.
  394. </description>
  395. </method>
  396. <method name="body_get_shape_transform" qualifiers="const">
  397. <return type="Transform2D" />
  398. <argument index="0" name="body" type="RID" />
  399. <argument index="1" name="shape_idx" type="int" />
  400. <description>
  401. Returns the transform matrix of a body shape.
  402. </description>
  403. </method>
  404. <method name="body_get_space" qualifiers="const">
  405. <return type="RID" />
  406. <argument index="0" name="body" type="RID" />
  407. <description>
  408. Returns the [RID] of the space assigned to a body.
  409. </description>
  410. </method>
  411. <method name="body_get_state" qualifiers="const">
  412. <return type="Variant" />
  413. <argument index="0" name="body" type="RID" />
  414. <argument index="1" name="state" type="int" enum="PhysicsServer2D.BodyState" />
  415. <description>
  416. Returns a body state.
  417. </description>
  418. </method>
  419. <method name="body_is_omitting_force_integration" qualifiers="const">
  420. <return type="bool" />
  421. <argument index="0" name="body" type="RID" />
  422. <description>
  423. Returns whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
  424. </description>
  425. </method>
  426. <method name="body_remove_collision_exception">
  427. <return type="void" />
  428. <argument index="0" name="body" type="RID" />
  429. <argument index="1" name="excepted_body" type="RID" />
  430. <description>
  431. Removes a body from the list of bodies exempt from collisions.
  432. </description>
  433. </method>
  434. <method name="body_remove_shape">
  435. <return type="void" />
  436. <argument index="0" name="body" type="RID" />
  437. <argument index="1" name="shape_idx" type="int" />
  438. <description>
  439. Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.
  440. </description>
  441. </method>
  442. <method name="body_reset_mass_properties">
  443. <return type="void" />
  444. <argument index="0" name="body" type="RID" />
  445. <description>
  446. Restores the default inertia and center of mass based on shapes to cancel any custom values previously set using [method body_set_param].
  447. </description>
  448. </method>
  449. <method name="body_set_axis_velocity">
  450. <return type="void" />
  451. <argument index="0" name="body" type="RID" />
  452. <argument index="1" name="axis_velocity" type="Vector2" />
  453. <description>
  454. Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
  455. </description>
  456. </method>
  457. <method name="body_set_collision_layer">
  458. <return type="void" />
  459. <argument index="0" name="body" type="RID" />
  460. <argument index="1" name="layer" type="int" />
  461. <description>
  462. Sets the physics layer or layers a body belongs to.
  463. </description>
  464. </method>
  465. <method name="body_set_collision_mask">
  466. <return type="void" />
  467. <argument index="0" name="body" type="RID" />
  468. <argument index="1" name="mask" type="int" />
  469. <description>
  470. Sets the physics layer or layers a body can collide with.
  471. </description>
  472. </method>
  473. <method name="body_set_continuous_collision_detection_mode">
  474. <return type="void" />
  475. <argument index="0" name="body" type="RID" />
  476. <argument index="1" name="mode" type="int" enum="PhysicsServer2D.CCDMode" />
  477. <description>
  478. Sets the continuous collision detection mode using one of the [enum CCDMode] constants.
  479. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.
  480. </description>
  481. </method>
  482. <method name="body_set_force_integration_callback">
  483. <return type="void" />
  484. <argument index="0" name="body" type="RID" />
  485. <argument index="1" name="callable" type="Callable" />
  486. <argument index="2" name="userdata" type="Variant" default="null" />
  487. <description>
  488. Sets the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force_integration]).
  489. The force integration function takes 2 arguments:
  490. [code]state:[/code] [PhysicsDirectBodyState2D] used to retrieve and modify the body's state.
  491. [code]userdata:[/code] Optional user data, if it was passed when calling [code]body_set_force_integration_callback[/code].
  492. </description>
  493. </method>
  494. <method name="body_set_max_contacts_reported">
  495. <return type="void" />
  496. <argument index="0" name="body" type="RID" />
  497. <argument index="1" name="amount" type="int" />
  498. <description>
  499. Sets the maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
  500. </description>
  501. </method>
  502. <method name="body_set_mode">
  503. <return type="void" />
  504. <argument index="0" name="body" type="RID" />
  505. <argument index="1" name="mode" type="int" enum="PhysicsServer2D.BodyMode" />
  506. <description>
  507. Sets the body mode using one of the [enum BodyMode] constants.
  508. </description>
  509. </method>
  510. <method name="body_set_omit_force_integration">
  511. <return type="void" />
  512. <argument index="0" name="body" type="RID" />
  513. <argument index="1" name="enable" type="bool" />
  514. <description>
  515. Sets whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
  516. </description>
  517. </method>
  518. <method name="body_set_param">
  519. <return type="void" />
  520. <argument index="0" name="body" type="RID" />
  521. <argument index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter" />
  522. <argument index="2" name="value" type="Variant" />
  523. <description>
  524. Sets a body parameter. See [enum BodyParameter] for a list of available parameters.
  525. </description>
  526. </method>
  527. <method name="body_set_shape">
  528. <return type="void" />
  529. <argument index="0" name="body" type="RID" />
  530. <argument index="1" name="shape_idx" type="int" />
  531. <argument index="2" name="shape" type="RID" />
  532. <description>
  533. Substitutes a given body shape by another. The old shape is selected by its index, the new one by its [RID].
  534. </description>
  535. </method>
  536. <method name="body_set_shape_as_one_way_collision">
  537. <return type="void" />
  538. <argument index="0" name="body" type="RID" />
  539. <argument index="1" name="shape_idx" type="int" />
  540. <argument index="2" name="enable" type="bool" />
  541. <argument index="3" name="margin" type="float" />
  542. <description>
  543. Enables one way collision on body if [code]enable[/code] is [code]true[/code].
  544. </description>
  545. </method>
  546. <method name="body_set_shape_disabled">
  547. <return type="void" />
  548. <argument index="0" name="body" type="RID" />
  549. <argument index="1" name="shape_idx" type="int" />
  550. <argument index="2" name="disabled" type="bool" />
  551. <description>
  552. Disables shape in body if [code]disable[/code] is [code]true[/code].
  553. </description>
  554. </method>
  555. <method name="body_set_shape_transform">
  556. <return type="void" />
  557. <argument index="0" name="body" type="RID" />
  558. <argument index="1" name="shape_idx" type="int" />
  559. <argument index="2" name="transform" type="Transform2D" />
  560. <description>
  561. Sets the transform matrix for a body shape.
  562. </description>
  563. </method>
  564. <method name="body_set_space">
  565. <return type="void" />
  566. <argument index="0" name="body" type="RID" />
  567. <argument index="1" name="space" type="RID" />
  568. <description>
  569. Assigns a space to the body (see [method space_create]).
  570. </description>
  571. </method>
  572. <method name="body_set_state">
  573. <return type="void" />
  574. <argument index="0" name="body" type="RID" />
  575. <argument index="1" name="state" type="int" enum="PhysicsServer2D.BodyState" />
  576. <argument index="2" name="value" type="Variant" />
  577. <description>
  578. Sets a body state using one of the [enum BodyState] constants.
  579. Note that the method doesn't take effect immediately. The state will change on the next physics frame.
  580. </description>
  581. </method>
  582. <method name="body_test_motion">
  583. <return type="bool" />
  584. <argument index="0" name="body" type="RID" />
  585. <argument index="1" name="parameters" type="PhysicsTestMotionParameters2D" />
  586. <argument index="2" name="result" type="PhysicsTestMotionResult2D" default="null" />
  587. <description>
  588. Returns [code]true[/code] if a collision would result from moving along a motion vector from a given point in space. [PhysicsTestMotionParameters2D] is passed to set motion parameters. [PhysicsTestMotionResult2D] can be passed to return additional information.
  589. </description>
  590. </method>
  591. <method name="capsule_shape_create">
  592. <return type="RID" />
  593. <description>
  594. </description>
  595. </method>
  596. <method name="circle_shape_create">
  597. <return type="RID" />
  598. <description>
  599. </description>
  600. </method>
  601. <method name="concave_polygon_shape_create">
  602. <return type="RID" />
  603. <description>
  604. </description>
  605. </method>
  606. <method name="convex_polygon_shape_create">
  607. <return type="RID" />
  608. <description>
  609. </description>
  610. </method>
  611. <method name="damped_spring_joint_get_param" qualifiers="const">
  612. <return type="float" />
  613. <argument index="0" name="joint" type="RID" />
  614. <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam" />
  615. <description>
  616. Returns the value of a damped spring joint parameter. See [enum DampedSpringParam] for a list of available parameters.
  617. </description>
  618. </method>
  619. <method name="damped_spring_joint_set_param">
  620. <return type="void" />
  621. <argument index="0" name="joint" type="RID" />
  622. <argument index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam" />
  623. <argument index="2" name="value" type="float" />
  624. <description>
  625. Sets a damped spring joint parameter. See [enum DampedSpringParam] for a list of available parameters.
  626. </description>
  627. </method>
  628. <method name="free_rid">
  629. <return type="void" />
  630. <argument index="0" name="rid" type="RID" />
  631. <description>
  632. Destroys any of the objects created by PhysicsServer2D. If the [RID] passed is not one of the objects that can be created by PhysicsServer2D, an error will be sent to the console.
  633. </description>
  634. </method>
  635. <method name="get_process_info">
  636. <return type="int" />
  637. <argument index="0" name="process_info" type="int" enum="PhysicsServer2D.ProcessInfo" />
  638. <description>
  639. Returns information about the current state of the 2D physics engine. See [enum ProcessInfo] for a list of available states.
  640. </description>
  641. </method>
  642. <method name="joint_clear">
  643. <return type="void" />
  644. <argument index="0" name="joint" type="RID" />
  645. <description>
  646. </description>
  647. </method>
  648. <method name="joint_create">
  649. <return type="RID" />
  650. <description>
  651. </description>
  652. </method>
  653. <method name="joint_get_param" qualifiers="const">
  654. <return type="float" />
  655. <argument index="0" name="joint" type="RID" />
  656. <argument index="1" name="param" type="int" enum="PhysicsServer2D.JointParam" />
  657. <description>
  658. Returns the value of a joint parameter.
  659. </description>
  660. </method>
  661. <method name="joint_get_type" qualifiers="const">
  662. <return type="int" enum="PhysicsServer2D.JointType" />
  663. <argument index="0" name="joint" type="RID" />
  664. <description>
  665. Returns a joint's type (see [enum JointType]).
  666. </description>
  667. </method>
  668. <method name="joint_make_damped_spring">
  669. <return type="void" />
  670. <argument index="0" name="joint" type="RID" />
  671. <argument index="1" name="anchor_a" type="Vector2" />
  672. <argument index="2" name="anchor_b" type="Vector2" />
  673. <argument index="3" name="body_a" type="RID" />
  674. <argument index="4" name="body_b" type="RID" />
  675. <description>
  676. </description>
  677. </method>
  678. <method name="joint_make_groove">
  679. <return type="void" />
  680. <argument index="0" name="joint" type="RID" />
  681. <argument index="1" name="groove1_a" type="Vector2" />
  682. <argument index="2" name="groove2_a" type="Vector2" />
  683. <argument index="3" name="anchor_b" type="Vector2" />
  684. <argument index="4" name="body_a" type="RID" />
  685. <argument index="5" name="body_b" type="RID" />
  686. <description>
  687. </description>
  688. </method>
  689. <method name="joint_make_pin">
  690. <return type="void" />
  691. <argument index="0" name="joint" type="RID" />
  692. <argument index="1" name="anchor" type="Vector2" />
  693. <argument index="2" name="body_a" type="RID" />
  694. <argument index="3" name="body_b" type="RID" />
  695. <description>
  696. </description>
  697. </method>
  698. <method name="joint_set_param">
  699. <return type="void" />
  700. <argument index="0" name="joint" type="RID" />
  701. <argument index="1" name="param" type="int" enum="PhysicsServer2D.JointParam" />
  702. <argument index="2" name="value" type="float" />
  703. <description>
  704. Sets a joint parameter. See [enum JointParam] for a list of available parameters.
  705. </description>
  706. </method>
  707. <method name="rectangle_shape_create">
  708. <return type="RID" />
  709. <description>
  710. </description>
  711. </method>
  712. <method name="segment_shape_create">
  713. <return type="RID" />
  714. <description>
  715. </description>
  716. </method>
  717. <method name="separation_ray_shape_create">
  718. <return type="RID" />
  719. <description>
  720. </description>
  721. </method>
  722. <method name="set_active">
  723. <return type="void" />
  724. <argument index="0" name="active" type="bool" />
  725. <description>
  726. Activates or deactivates the 2D physics engine.
  727. </description>
  728. </method>
  729. <method name="set_collision_iterations">
  730. <return type="void" />
  731. <argument index="0" name="iterations" type="int" />
  732. <description>
  733. Sets the amount of iterations for calculating velocities of colliding bodies. The greater the amount of iterations, the more accurate the collisions will be. However, a greater amount of iterations requires more CPU power, which can decrease performance. The default value is [code]8[/code].
  734. </description>
  735. </method>
  736. <method name="shape_get_data" qualifiers="const">
  737. <return type="Variant" />
  738. <argument index="0" name="shape" type="RID" />
  739. <description>
  740. Returns the shape data.
  741. </description>
  742. </method>
  743. <method name="shape_get_type" qualifiers="const">
  744. <return type="int" enum="PhysicsServer2D.ShapeType" />
  745. <argument index="0" name="shape" type="RID" />
  746. <description>
  747. Returns a shape's type (see [enum ShapeType]).
  748. </description>
  749. </method>
  750. <method name="shape_set_data">
  751. <return type="void" />
  752. <argument index="0" name="shape" type="RID" />
  753. <argument index="1" name="data" type="Variant" />
  754. <description>
  755. Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created [method shape_get_type].
  756. </description>
  757. </method>
  758. <method name="space_create">
  759. <return type="RID" />
  760. <description>
  761. Creates a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with [method area_set_space], or to a body with [method body_set_space].
  762. </description>
  763. </method>
  764. <method name="space_get_direct_state">
  765. <return type="PhysicsDirectSpaceState2D" />
  766. <argument index="0" name="space" type="RID" />
  767. <description>
  768. Returns the state of a space, a [PhysicsDirectSpaceState2D]. This object can be used to make collision/intersection queries.
  769. </description>
  770. </method>
  771. <method name="space_get_param" qualifiers="const">
  772. <return type="float" />
  773. <argument index="0" name="space" type="RID" />
  774. <argument index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter" />
  775. <description>
  776. Returns the value of a space parameter.
  777. </description>
  778. </method>
  779. <method name="space_is_active" qualifiers="const">
  780. <return type="bool" />
  781. <argument index="0" name="space" type="RID" />
  782. <description>
  783. Returns whether the space is active.
  784. </description>
  785. </method>
  786. <method name="space_set_active">
  787. <return type="void" />
  788. <argument index="0" name="space" type="RID" />
  789. <argument index="1" name="active" type="bool" />
  790. <description>
  791. Marks a space as active. It will not have an effect, unless it is assigned to an area or body.
  792. </description>
  793. </method>
  794. <method name="space_set_param">
  795. <return type="void" />
  796. <argument index="0" name="space" type="RID" />
  797. <argument index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter" />
  798. <argument index="2" name="value" type="float" />
  799. <description>
  800. Sets the value for a space parameter. See [enum SpaceParameter] for a list of available parameters.
  801. </description>
  802. </method>
  803. <method name="world_boundary_shape_create">
  804. <return type="RID" />
  805. <description>
  806. </description>
  807. </method>
  808. </methods>
  809. <constants>
  810. <constant name="SPACE_PARAM_CONTACT_RECYCLE_RADIUS" value="0" enum="SpaceParameter">
  811. Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated.
  812. </constant>
  813. <constant name="SPACE_PARAM_CONTACT_MAX_SEPARATION" value="1" enum="SpaceParameter">
  814. Constant to set/get the maximum distance a shape can be from another before they are considered separated.
  815. </constant>
  816. <constant name="SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION" value="2" enum="SpaceParameter">
  817. Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision.
  818. </constant>
  819. <constant name="SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD" value="3" enum="SpaceParameter">
  820. Constant to set/get the threshold linear velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given.
  821. </constant>
  822. <constant name="SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD" value="4" enum="SpaceParameter">
  823. Constant to set/get the threshold angular velocity of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after the time given.
  824. </constant>
  825. <constant name="SPACE_PARAM_BODY_TIME_TO_SLEEP" value="5" enum="SpaceParameter">
  826. Constant to set/get the maximum time of activity. A body marked as potentially inactive for both linear and angular velocity will be put to sleep after this time.
  827. </constant>
  828. <constant name="SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS" value="6" enum="SpaceParameter">
  829. Constant to set/get the default solver bias for all physics constraints. A solver bias is a factor controlling how much two objects "rebound", after violating a constraint, to avoid leaving them in that state because of numerical imprecision.
  830. </constant>
  831. <constant name="SHAPE_WORLD_BOUNDARY" value="0" enum="ShapeType">
  832. This is the constant for creating world boundary shapes. A world boundary shape is an [i]infinite[/i] line with an origin point, and a normal. Thus, it can be used for front/behind checks.
  833. </constant>
  834. <constant name="SHAPE_SEPARATION_RAY" value="1" enum="ShapeType">
  835. This is the constant for creating separation ray shapes. A separation ray is defined by a length and separates itself from what is touching its far endpoint. Useful for character controllers.
  836. </constant>
  837. <constant name="SHAPE_SEGMENT" value="2" enum="ShapeType">
  838. This is the constant for creating segment shapes. A segment shape is a [i]finite[/i] line from a point A to a point B. It can be checked for intersections.
  839. </constant>
  840. <constant name="SHAPE_CIRCLE" value="3" enum="ShapeType">
  841. This is the constant for creating circle shapes. A circle shape only has a radius. It can be used for intersections and inside/outside checks.
  842. </constant>
  843. <constant name="SHAPE_RECTANGLE" value="4" enum="ShapeType">
  844. This is the constant for creating rectangle shapes. A rectangle shape is defined by a width and a height. It can be used for intersections and inside/outside checks.
  845. </constant>
  846. <constant name="SHAPE_CAPSULE" value="5" enum="ShapeType">
  847. This is the constant for creating capsule shapes. A capsule shape is defined by a radius and a length. It can be used for intersections and inside/outside checks.
  848. </constant>
  849. <constant name="SHAPE_CONVEX_POLYGON" value="6" enum="ShapeType">
  850. This is the constant for creating convex polygon shapes. A polygon is defined by a list of points. It can be used for intersections and inside/outside checks. Unlike the [member CollisionPolygon2D.polygon] property, polygons modified with [method shape_set_data] do not verify that the points supplied form is a convex polygon.
  851. </constant>
  852. <constant name="SHAPE_CONCAVE_POLYGON" value="7" enum="ShapeType">
  853. This is the constant for creating concave polygon shapes. A polygon is defined by a list of points. It can be used for intersections checks, but not for inside/outside checks.
  854. </constant>
  855. <constant name="SHAPE_CUSTOM" value="8" enum="ShapeType">
  856. This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
  857. </constant>
  858. <constant name="AREA_PARAM_GRAVITY" value="0" enum="AreaParameter">
  859. Constant to set/get gravity strength in an area.
  860. </constant>
  861. <constant name="AREA_PARAM_GRAVITY_VECTOR" value="1" enum="AreaParameter">
  862. Constant to set/get gravity vector/center in an area.
  863. </constant>
  864. <constant name="AREA_PARAM_GRAVITY_IS_POINT" value="2" enum="AreaParameter">
  865. Constant to set/get whether the gravity vector of an area is a direction, or a center point.
  866. </constant>
  867. <constant name="AREA_PARAM_GRAVITY_DISTANCE_SCALE" value="3" enum="AreaParameter">
  868. Constant to set/get the falloff factor for point gravity of an area. The greater this value is, the faster the strength of gravity decreases with the square of distance.
  869. </constant>
  870. <constant name="AREA_PARAM_GRAVITY_POINT_ATTENUATION" value="4" enum="AreaParameter">
  871. This constant was used to set/get the falloff factor for point gravity. It has been superseded by [constant AREA_PARAM_GRAVITY_DISTANCE_SCALE].
  872. </constant>
  873. <constant name="AREA_PARAM_LINEAR_DAMP" value="5" enum="AreaParameter">
  874. Constant to set/get the linear dampening factor of an area.
  875. </constant>
  876. <constant name="AREA_PARAM_ANGULAR_DAMP" value="6" enum="AreaParameter">
  877. Constant to set/get the angular dampening factor of an area.
  878. </constant>
  879. <constant name="AREA_PARAM_PRIORITY" value="7" enum="AreaParameter">
  880. Constant to set/get the priority (order of processing) of an area.
  881. </constant>
  882. <constant name="AREA_SPACE_OVERRIDE_DISABLED" value="0" enum="AreaSpaceOverrideMode">
  883. This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
  884. </constant>
  885. <constant name="AREA_SPACE_OVERRIDE_COMBINE" value="1" enum="AreaSpaceOverrideMode">
  886. This area adds its gravity/damp values to whatever has been calculated so far. This way, many overlapping areas can combine their physics to make interesting effects.
  887. </constant>
  888. <constant name="AREA_SPACE_OVERRIDE_COMBINE_REPLACE" value="2" enum="AreaSpaceOverrideMode">
  889. This area adds its gravity/damp values to whatever has been calculated so far. Then stops taking into account the rest of the areas, even the default one.
  890. </constant>
  891. <constant name="AREA_SPACE_OVERRIDE_REPLACE" value="3" enum="AreaSpaceOverrideMode">
  892. This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
  893. </constant>
  894. <constant name="AREA_SPACE_OVERRIDE_REPLACE_COMBINE" value="4" enum="AreaSpaceOverrideMode">
  895. This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
  896. </constant>
  897. <constant name="BODY_MODE_STATIC" value="0" enum="BodyMode">
  898. Constant for static bodies. In this mode, a body can be only moved by user code and doesn't collide with other bodies along its path when moved.
  899. </constant>
  900. <constant name="BODY_MODE_KINEMATIC" value="1" enum="BodyMode">
  901. Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path.
  902. </constant>
  903. <constant name="BODY_MODE_DYNAMIC" value="2" enum="BodyMode">
  904. Constant for dynamic bodies. In this mode, a body can be pushed by other bodies and has forces applied.
  905. </constant>
  906. <constant name="BODY_MODE_DYNAMIC_LINEAR" value="3" enum="BodyMode">
  907. Constant for linear dynamic bodies. In this mode, a body is dynamic but can not rotate, and only its linear velocity is affected by external forces.
  908. </constant>
  909. <constant name="BODY_PARAM_BOUNCE" value="0" enum="BodyParameter">
  910. Constant to set/get a body's bounce factor.
  911. </constant>
  912. <constant name="BODY_PARAM_FRICTION" value="1" enum="BodyParameter">
  913. Constant to set/get a body's friction.
  914. </constant>
  915. <constant name="BODY_PARAM_MASS" value="2" enum="BodyParameter">
  916. Constant to set/get a body's mass.
  917. </constant>
  918. <constant name="BODY_PARAM_INERTIA" value="3" enum="BodyParameter">
  919. Constant to set/get a body's inertia.
  920. </constant>
  921. <constant name="BODY_PARAM_CENTER_OF_MASS" value="4" enum="BodyParameter">
  922. Constant to set/get a body's center of mass.
  923. </constant>
  924. <constant name="BODY_PARAM_GRAVITY_SCALE" value="5" enum="BodyParameter">
  925. Constant to set/get a body's gravity multiplier.
  926. </constant>
  927. <constant name="BODY_PARAM_LINEAR_DAMP_MODE" value="6" enum="BodyParameter">
  928. Constant to set/get a body's linear dampening mode. See [enum BodyDampMode] for possible values.
  929. </constant>
  930. <constant name="BODY_PARAM_ANGULAR_DAMP_MODE" value="7" enum="BodyParameter">
  931. Constant to set/get a body's angular dampening mode. See [enum BodyDampMode] for possible values.
  932. </constant>
  933. <constant name="BODY_PARAM_LINEAR_DAMP" value="8" enum="BodyParameter">
  934. Constant to set/get a body's linear dampening factor.
  935. </constant>
  936. <constant name="BODY_PARAM_ANGULAR_DAMP" value="9" enum="BodyParameter">
  937. Constant to set/get a body's angular dampening factor.
  938. </constant>
  939. <constant name="BODY_PARAM_MAX" value="10" enum="BodyParameter">
  940. Represents the size of the [enum BodyParameter] enum.
  941. </constant>
  942. <constant name="BODY_DAMP_MODE_COMBINE" value="0" enum="BodyDampMode">
  943. The body's damping value is added to any value set in areas or the default value.
  944. </constant>
  945. <constant name="BODY_DAMP_MODE_REPLACE" value="1" enum="BodyDampMode">
  946. The body's damping value replaces any value set in areas or the default value.
  947. </constant>
  948. <constant name="BODY_STATE_TRANSFORM" value="0" enum="BodyState">
  949. Constant to set/get the current transform matrix of the body.
  950. </constant>
  951. <constant name="BODY_STATE_LINEAR_VELOCITY" value="1" enum="BodyState">
  952. Constant to set/get the current linear velocity of the body.
  953. </constant>
  954. <constant name="BODY_STATE_ANGULAR_VELOCITY" value="2" enum="BodyState">
  955. Constant to set/get the current angular velocity of the body.
  956. </constant>
  957. <constant name="BODY_STATE_SLEEPING" value="3" enum="BodyState">
  958. Constant to sleep/wake up a body, or to get whether it is sleeping.
  959. </constant>
  960. <constant name="BODY_STATE_CAN_SLEEP" value="4" enum="BodyState">
  961. Constant to set/get whether the body can sleep.
  962. </constant>
  963. <constant name="JOINT_TYPE_PIN" value="0" enum="JointType">
  964. Constant to create pin joints.
  965. </constant>
  966. <constant name="JOINT_TYPE_GROOVE" value="1" enum="JointType">
  967. Constant to create groove joints.
  968. </constant>
  969. <constant name="JOINT_TYPE_DAMPED_SPRING" value="2" enum="JointType">
  970. Constant to create damped spring joints.
  971. </constant>
  972. <constant name="JOINT_TYPE_MAX" value="3" enum="JointType">
  973. Represents the size of the [enum JointType] enum.
  974. </constant>
  975. <constant name="JOINT_PARAM_BIAS" value="0" enum="JointParam">
  976. </constant>
  977. <constant name="JOINT_PARAM_MAX_BIAS" value="1" enum="JointParam">
  978. </constant>
  979. <constant name="JOINT_PARAM_MAX_FORCE" value="2" enum="JointParam">
  980. </constant>
  981. <constant name="DAMPED_SPRING_REST_LENGTH" value="0" enum="DampedSpringParam">
  982. Sets the resting length of the spring joint. The joint will always try to go to back this length when pulled apart.
  983. </constant>
  984. <constant name="DAMPED_SPRING_STIFFNESS" value="1" enum="DampedSpringParam">
  985. Sets the stiffness of the spring joint. The joint applies a force equal to the stiffness times the distance from its resting length.
  986. </constant>
  987. <constant name="DAMPED_SPRING_DAMPING" value="2" enum="DampedSpringParam">
  988. Sets the damping ratio of the spring joint. A value of 0 indicates an undamped spring, while 1 causes the system to reach equilibrium as fast as possible (critical damping).
  989. </constant>
  990. <constant name="CCD_MODE_DISABLED" value="0" enum="CCDMode">
  991. Disables continuous collision detection. This is the fastest way to detect body collisions, but can miss small, fast-moving objects.
  992. </constant>
  993. <constant name="CCD_MODE_CAST_RAY" value="1" enum="CCDMode">
  994. Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise.
  995. </constant>
  996. <constant name="CCD_MODE_CAST_SHAPE" value="2" enum="CCDMode">
  997. Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise.
  998. </constant>
  999. <constant name="AREA_BODY_ADDED" value="0" enum="AreaBodyStatus">
  1000. The value of the first parameter and area callback function receives, when an object enters one of its shapes.
  1001. </constant>
  1002. <constant name="AREA_BODY_REMOVED" value="1" enum="AreaBodyStatus">
  1003. The value of the first parameter and area callback function receives, when an object exits one of its shapes.
  1004. </constant>
  1005. <constant name="INFO_ACTIVE_OBJECTS" value="0" enum="ProcessInfo">
  1006. Constant to get the number of objects that are not sleeping.
  1007. </constant>
  1008. <constant name="INFO_COLLISION_PAIRS" value="1" enum="ProcessInfo">
  1009. Constant to get the number of possible collisions.
  1010. </constant>
  1011. <constant name="INFO_ISLAND_COUNT" value="2" enum="ProcessInfo">
  1012. Constant to get the number of space regions where a collision could occur.
  1013. </constant>
  1014. </constants>
  1015. </class>