Physics2DServer.xml 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Physics2DServer" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Server interface for low-level 2D physics access.
  5. </brief_description>
  6. <description>
  7. Physics2DServer 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="Physics2DServer.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="Physics2DServer.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="receiver" type="Object" />
  127. <argument index="2" name="method" type="String" />
  128. <description>
  129. </description>
  130. </method>
  131. <method name="area_set_collision_layer">
  132. <return type="void" />
  133. <argument index="0" name="area" type="RID" />
  134. <argument index="1" name="layer" type="int" />
  135. <description>
  136. Assigns the area to one or many physics layers.
  137. </description>
  138. </method>
  139. <method name="area_set_collision_mask">
  140. <return type="void" />
  141. <argument index="0" name="area" type="RID" />
  142. <argument index="1" name="mask" type="int" />
  143. <description>
  144. Sets which physics layers the area will monitor.
  145. </description>
  146. </method>
  147. <method name="area_set_monitor_callback">
  148. <return type="void" />
  149. <argument index="0" name="area" type="RID" />
  150. <argument index="1" name="receiver" type="Object" />
  151. <argument index="2" name="method" type="String" />
  152. <description>
  153. 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:
  154. 1: [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED], depending on whether the object entered or exited the area.
  155. 2: [RID] of the object that entered/exited the area.
  156. 3: Instance ID of the object that entered/exited the area.
  157. 4: The shape index of the object that entered/exited the area.
  158. 5: The shape index of the area where the object entered/exited.
  159. </description>
  160. </method>
  161. <method name="area_set_monitorable">
  162. <return type="void" />
  163. <argument index="0" name="area" type="RID" />
  164. <argument index="1" name="monitorable" type="bool" />
  165. <description>
  166. </description>
  167. </method>
  168. <method name="area_set_param">
  169. <return type="void" />
  170. <argument index="0" name="area" type="RID" />
  171. <argument index="1" name="param" type="int" enum="Physics2DServer.AreaParameter" />
  172. <argument index="2" name="value" type="Variant" />
  173. <description>
  174. Sets the value for an area parameter. See [enum AreaParameter] for a list of available parameters.
  175. </description>
  176. </method>
  177. <method name="area_set_shape">
  178. <return type="void" />
  179. <argument index="0" name="area" type="RID" />
  180. <argument index="1" name="shape_idx" type="int" />
  181. <argument index="2" name="shape" type="RID" />
  182. <description>
  183. Substitutes a given area shape by another. The old shape is selected by its index, the new one by its [RID].
  184. </description>
  185. </method>
  186. <method name="area_set_shape_disabled">
  187. <return type="void" />
  188. <argument index="0" name="area" type="RID" />
  189. <argument index="1" name="shape_idx" type="int" />
  190. <argument index="2" name="disabled" type="bool" />
  191. <description>
  192. Disables a given shape in an area.
  193. </description>
  194. </method>
  195. <method name="area_set_shape_transform">
  196. <return type="void" />
  197. <argument index="0" name="area" type="RID" />
  198. <argument index="1" name="shape_idx" type="int" />
  199. <argument index="2" name="transform" type="Transform2D" />
  200. <description>
  201. Sets the transform matrix for an area shape.
  202. </description>
  203. </method>
  204. <method name="area_set_space">
  205. <return type="void" />
  206. <argument index="0" name="area" type="RID" />
  207. <argument index="1" name="space" type="RID" />
  208. <description>
  209. Assigns a space to the area.
  210. </description>
  211. </method>
  212. <method name="area_set_space_override_mode">
  213. <return type="void" />
  214. <argument index="0" name="area" type="RID" />
  215. <argument index="1" name="mode" type="int" enum="Physics2DServer.AreaSpaceOverrideMode" />
  216. <description>
  217. Sets the space override mode for the area. See [enum AreaSpaceOverrideMode] for a list of available modes.
  218. </description>
  219. </method>
  220. <method name="area_set_transform">
  221. <return type="void" />
  222. <argument index="0" name="area" type="RID" />
  223. <argument index="1" name="transform" type="Transform2D" />
  224. <description>
  225. Sets the transform matrix for an area.
  226. </description>
  227. </method>
  228. <method name="body_add_central_force">
  229. <return type="void" />
  230. <argument index="0" name="body" type="RID" />
  231. <argument index="1" name="force" type="Vector2" />
  232. <description>
  233. </description>
  234. </method>
  235. <method name="body_add_collision_exception">
  236. <return type="void" />
  237. <argument index="0" name="body" type="RID" />
  238. <argument index="1" name="excepted_body" type="RID" />
  239. <description>
  240. Adds a body to the list of bodies exempt from collisions.
  241. </description>
  242. </method>
  243. <method name="body_add_force">
  244. <return type="void" />
  245. <argument index="0" name="body" type="RID" />
  246. <argument index="1" name="offset" type="Vector2" />
  247. <argument index="2" name="force" type="Vector2" />
  248. <description>
  249. 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.
  250. </description>
  251. </method>
  252. <method name="body_add_shape">
  253. <return type="void" />
  254. <argument index="0" name="body" type="RID" />
  255. <argument index="1" name="shape" type="RID" />
  256. <argument index="2" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )" />
  257. <argument index="3" name="disabled" type="bool" default="false" />
  258. <description>
  259. 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.
  260. </description>
  261. </method>
  262. <method name="body_add_torque">
  263. <return type="void" />
  264. <argument index="0" name="body" type="RID" />
  265. <argument index="1" name="torque" type="float" />
  266. <description>
  267. </description>
  268. </method>
  269. <method name="body_apply_central_impulse">
  270. <return type="void" />
  271. <argument index="0" name="body" type="RID" />
  272. <argument index="1" name="impulse" type="Vector2" />
  273. <description>
  274. </description>
  275. </method>
  276. <method name="body_apply_impulse">
  277. <return type="void" />
  278. <argument index="0" name="body" type="RID" />
  279. <argument index="1" name="position" type="Vector2" />
  280. <argument index="2" name="impulse" type="Vector2" />
  281. <description>
  282. Adds a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates.
  283. </description>
  284. </method>
  285. <method name="body_apply_torque_impulse">
  286. <return type="void" />
  287. <argument index="0" name="body" type="RID" />
  288. <argument index="1" name="impulse" type="float" />
  289. <description>
  290. </description>
  291. </method>
  292. <method name="body_attach_canvas_instance_id">
  293. <return type="void" />
  294. <argument index="0" name="body" type="RID" />
  295. <argument index="1" name="id" type="int" />
  296. <description>
  297. </description>
  298. </method>
  299. <method name="body_attach_object_instance_id">
  300. <return type="void" />
  301. <argument index="0" name="body" type="RID" />
  302. <argument index="1" name="id" type="int" />
  303. <description>
  304. Assigns the area to a descendant of [Object], so it can exist in the node tree.
  305. </description>
  306. </method>
  307. <method name="body_clear_shapes">
  308. <return type="void" />
  309. <argument index="0" name="body" type="RID" />
  310. <description>
  311. Removes all shapes from a body.
  312. </description>
  313. </method>
  314. <method name="body_create">
  315. <return type="RID" />
  316. <description>
  317. Creates a physics body.
  318. </description>
  319. </method>
  320. <method name="body_get_canvas_instance_id" qualifiers="const">
  321. <return type="int" />
  322. <argument index="0" name="body" type="RID" />
  323. <description>
  324. </description>
  325. </method>
  326. <method name="body_get_collision_layer" qualifiers="const">
  327. <return type="int" />
  328. <argument index="0" name="body" type="RID" />
  329. <description>
  330. Returns the physics layer or layers a body belongs to.
  331. </description>
  332. </method>
  333. <method name="body_get_collision_mask" qualifiers="const">
  334. <return type="int" />
  335. <argument index="0" name="body" type="RID" />
  336. <description>
  337. Returns the physics layer or layers a body can collide with.
  338. </description>
  339. </method>
  340. <method name="body_get_continuous_collision_detection_mode" qualifiers="const">
  341. <return type="int" enum="Physics2DServer.CCDMode" />
  342. <argument index="0" name="body" type="RID" />
  343. <description>
  344. Returns the continuous collision detection mode.
  345. </description>
  346. </method>
  347. <method name="body_get_direct_state">
  348. <return type="Physics2DDirectBodyState" />
  349. <argument index="0" name="body" type="RID" />
  350. <description>
  351. Returns the [Physics2DDirectBodyState] of the body. Returns [code]null[/code] if the body is destroyed or removed from the physics space.
  352. </description>
  353. </method>
  354. <method name="body_get_max_contacts_reported" qualifiers="const">
  355. <return type="int" />
  356. <argument index="0" name="body" type="RID" />
  357. <description>
  358. Returns the maximum contacts that can be reported. See [method body_set_max_contacts_reported].
  359. </description>
  360. </method>
  361. <method name="body_get_mode" qualifiers="const">
  362. <return type="int" enum="Physics2DServer.BodyMode" />
  363. <argument index="0" name="body" type="RID" />
  364. <description>
  365. Returns the body mode.
  366. </description>
  367. </method>
  368. <method name="body_get_object_instance_id" qualifiers="const">
  369. <return type="int" />
  370. <argument index="0" name="body" type="RID" />
  371. <description>
  372. Gets the instance ID of the object the area is assigned to.
  373. </description>
  374. </method>
  375. <method name="body_get_param" qualifiers="const">
  376. <return type="float" />
  377. <argument index="0" name="body" type="RID" />
  378. <argument index="1" name="param" type="int" enum="Physics2DServer.BodyParameter" />
  379. <description>
  380. Returns the value of a body parameter. See [enum BodyParameter] for a list of available parameters.
  381. </description>
  382. </method>
  383. <method name="body_get_shape" qualifiers="const">
  384. <return type="RID" />
  385. <argument index="0" name="body" type="RID" />
  386. <argument index="1" name="shape_idx" type="int" />
  387. <description>
  388. Returns the [RID] of the nth shape of a body.
  389. </description>
  390. </method>
  391. <method name="body_get_shape_count" qualifiers="const">
  392. <return type="int" />
  393. <argument index="0" name="body" type="RID" />
  394. <description>
  395. Returns the number of shapes assigned to a body.
  396. </description>
  397. </method>
  398. <method name="body_get_shape_metadata" qualifiers="const">
  399. <return type="Variant" />
  400. <argument index="0" name="body" type="RID" />
  401. <argument index="1" name="shape_idx" type="int" />
  402. <description>
  403. Returns the metadata of a shape of a body.
  404. </description>
  405. </method>
  406. <method name="body_get_shape_transform" qualifiers="const">
  407. <return type="Transform2D" />
  408. <argument index="0" name="body" type="RID" />
  409. <argument index="1" name="shape_idx" type="int" />
  410. <description>
  411. Returns the transform matrix of a body shape.
  412. </description>
  413. </method>
  414. <method name="body_get_space" qualifiers="const">
  415. <return type="RID" />
  416. <argument index="0" name="body" type="RID" />
  417. <description>
  418. Returns the [RID] of the space assigned to a body.
  419. </description>
  420. </method>
  421. <method name="body_get_state" qualifiers="const">
  422. <return type="Variant" />
  423. <argument index="0" name="body" type="RID" />
  424. <argument index="1" name="state" type="int" enum="Physics2DServer.BodyState" />
  425. <description>
  426. Returns a body state.
  427. </description>
  428. </method>
  429. <method name="body_is_omitting_force_integration" qualifiers="const">
  430. <return type="bool" />
  431. <argument index="0" name="body" type="RID" />
  432. <description>
  433. Returns whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
  434. </description>
  435. </method>
  436. <method name="body_remove_collision_exception">
  437. <return type="void" />
  438. <argument index="0" name="body" type="RID" />
  439. <argument index="1" name="excepted_body" type="RID" />
  440. <description>
  441. Removes a body from the list of bodies exempt from collisions.
  442. </description>
  443. </method>
  444. <method name="body_remove_shape">
  445. <return type="void" />
  446. <argument index="0" name="body" type="RID" />
  447. <argument index="1" name="shape_idx" type="int" />
  448. <description>
  449. Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.
  450. </description>
  451. </method>
  452. <method name="body_set_axis_velocity">
  453. <return type="void" />
  454. <argument index="0" name="body" type="RID" />
  455. <argument index="1" name="axis_velocity" type="Vector2" />
  456. <description>
  457. 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.
  458. </description>
  459. </method>
  460. <method name="body_set_collision_layer">
  461. <return type="void" />
  462. <argument index="0" name="body" type="RID" />
  463. <argument index="1" name="layer" type="int" />
  464. <description>
  465. Sets the physics layer or layers a body belongs to.
  466. </description>
  467. </method>
  468. <method name="body_set_collision_mask">
  469. <return type="void" />
  470. <argument index="0" name="body" type="RID" />
  471. <argument index="1" name="mask" type="int" />
  472. <description>
  473. Sets the physics layer or layers a body can collide with.
  474. </description>
  475. </method>
  476. <method name="body_set_continuous_collision_detection_mode">
  477. <return type="void" />
  478. <argument index="0" name="body" type="RID" />
  479. <argument index="1" name="mode" type="int" enum="Physics2DServer.CCDMode" />
  480. <description>
  481. Sets the continuous collision detection mode using one of the [enum CCDMode] constants.
  482. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.
  483. </description>
  484. </method>
  485. <method name="body_set_force_integration_callback">
  486. <return type="void" />
  487. <argument index="0" name="body" type="RID" />
  488. <argument index="1" name="receiver" type="Object" />
  489. <argument index="2" name="method" type="String" />
  490. <argument index="3" name="userdata" type="Variant" default="null" />
  491. <description>
  492. Sets the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force_integration]).
  493. </description>
  494. </method>
  495. <method name="body_set_max_contacts_reported">
  496. <return type="void" />
  497. <argument index="0" name="body" type="RID" />
  498. <argument index="1" name="amount" type="int" />
  499. <description>
  500. 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.
  501. </description>
  502. </method>
  503. <method name="body_set_mode">
  504. <return type="void" />
  505. <argument index="0" name="body" type="RID" />
  506. <argument index="1" name="mode" type="int" enum="Physics2DServer.BodyMode" />
  507. <description>
  508. Sets the body mode using one of the [enum BodyMode] constants.
  509. </description>
  510. </method>
  511. <method name="body_set_omit_force_integration">
  512. <return type="void" />
  513. <argument index="0" name="body" type="RID" />
  514. <argument index="1" name="enable" type="bool" />
  515. <description>
  516. Sets whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
  517. </description>
  518. </method>
  519. <method name="body_set_param">
  520. <return type="void" />
  521. <argument index="0" name="body" type="RID" />
  522. <argument index="1" name="param" type="int" enum="Physics2DServer.BodyParameter" />
  523. <argument index="2" name="value" type="float" />
  524. <description>
  525. Sets a body parameter. See [enum BodyParameter] for a list of available parameters.
  526. </description>
  527. </method>
  528. <method name="body_set_shape">
  529. <return type="void" />
  530. <argument index="0" name="body" type="RID" />
  531. <argument index="1" name="shape_idx" type="int" />
  532. <argument index="2" name="shape" type="RID" />
  533. <description>
  534. Substitutes a given body shape by another. The old shape is selected by its index, the new one by its [RID].
  535. </description>
  536. </method>
  537. <method name="body_set_shape_as_one_way_collision">
  538. <return type="void" />
  539. <argument index="0" name="body" type="RID" />
  540. <argument index="1" name="shape_idx" type="int" />
  541. <argument index="2" name="enable" type="bool" />
  542. <argument index="3" name="margin" type="float" />
  543. <description>
  544. Enables one way collision on body if [code]enable[/code] is [code]true[/code].
  545. </description>
  546. </method>
  547. <method name="body_set_shape_disabled">
  548. <return type="void" />
  549. <argument index="0" name="body" type="RID" />
  550. <argument index="1" name="shape_idx" type="int" />
  551. <argument index="2" name="disabled" type="bool" />
  552. <description>
  553. Disables shape in body if [code]disable[/code] is [code]true[/code].
  554. </description>
  555. </method>
  556. <method name="body_set_shape_metadata">
  557. <return type="void" />
  558. <argument index="0" name="body" type="RID" />
  559. <argument index="1" name="shape_idx" type="int" />
  560. <argument index="2" name="metadata" type="Variant" />
  561. <description>
  562. Sets metadata of a shape within a body. This metadata is different from [method Object.set_meta], and can be retrieved on shape queries.
  563. </description>
  564. </method>
  565. <method name="body_set_shape_transform">
  566. <return type="void" />
  567. <argument index="0" name="body" type="RID" />
  568. <argument index="1" name="shape_idx" type="int" />
  569. <argument index="2" name="transform" type="Transform2D" />
  570. <description>
  571. Sets the transform matrix for a body shape.
  572. </description>
  573. </method>
  574. <method name="body_set_space">
  575. <return type="void" />
  576. <argument index="0" name="body" type="RID" />
  577. <argument index="1" name="space" type="RID" />
  578. <description>
  579. Assigns a space to the body (see [method space_create]).
  580. </description>
  581. </method>
  582. <method name="body_set_state">
  583. <return type="void" />
  584. <argument index="0" name="body" type="RID" />
  585. <argument index="1" name="state" type="int" enum="Physics2DServer.BodyState" />
  586. <argument index="2" name="value" type="Variant" />
  587. <description>
  588. Sets a body state using one of the [enum BodyState] constants.
  589. Note that the method doesn't take effect immediately. The state will change on the next physics frame.
  590. </description>
  591. </method>
  592. <method name="body_test_motion">
  593. <return type="bool" />
  594. <argument index="0" name="body" type="RID" />
  595. <argument index="1" name="from" type="Transform2D" />
  596. <argument index="2" name="motion" type="Vector2" />
  597. <argument index="3" name="infinite_inertia" type="bool" />
  598. <argument index="4" name="margin" type="float" default="0.08" />
  599. <argument index="5" name="result" type="Physics2DTestMotionResult" default="null" />
  600. <argument index="6" name="exclude_raycast_shapes" type="bool" default="true" />
  601. <argument index="7" name="exclude" type="Array" default="[ ]" />
  602. <description>
  603. Returns [code]true[/code] if a collision would result from moving in the given direction from a given point in space. Margin increases the size of the shapes involved in the collision detection. [Physics2DTestMotionResult] can be passed to return additional information in.
  604. </description>
  605. </method>
  606. <method name="capsule_shape_create">
  607. <return type="RID" />
  608. <description>
  609. </description>
  610. </method>
  611. <method name="circle_shape_create">
  612. <return type="RID" />
  613. <description>
  614. </description>
  615. </method>
  616. <method name="concave_polygon_shape_create">
  617. <return type="RID" />
  618. <description>
  619. </description>
  620. </method>
  621. <method name="convex_polygon_shape_create">
  622. <return type="RID" />
  623. <description>
  624. </description>
  625. </method>
  626. <method name="damped_spring_joint_create">
  627. <return type="RID" />
  628. <argument index="0" name="anchor_a" type="Vector2" />
  629. <argument index="1" name="anchor_b" type="Vector2" />
  630. <argument index="2" name="body_a" type="RID" />
  631. <argument index="3" name="body_b" type="RID" />
  632. <description>
  633. Creates a damped spring joint between two bodies. If not specified, the second body is assumed to be the joint itself.
  634. </description>
  635. </method>
  636. <method name="damped_string_joint_get_param" qualifiers="const">
  637. <return type="float" />
  638. <argument index="0" name="joint" type="RID" />
  639. <argument index="1" name="param" type="int" enum="Physics2DServer.DampedStringParam" />
  640. <description>
  641. Returns the value of a damped spring joint parameter.
  642. </description>
  643. </method>
  644. <method name="damped_string_joint_set_param">
  645. <return type="void" />
  646. <argument index="0" name="joint" type="RID" />
  647. <argument index="1" name="param" type="int" enum="Physics2DServer.DampedStringParam" />
  648. <argument index="2" name="value" type="float" />
  649. <description>
  650. Sets a damped spring joint parameter. See [enum DampedStringParam] for a list of available parameters.
  651. </description>
  652. </method>
  653. <method name="free_rid">
  654. <return type="void" />
  655. <argument index="0" name="rid" type="RID" />
  656. <description>
  657. Destroys an object created by the Physics2DServer.
  658. [b]Note:[/b] See [method VisualServer.free_rid] for details on how to handle RIDs for freed objects.
  659. </description>
  660. </method>
  661. <method name="get_process_info">
  662. <return type="int" />
  663. <argument index="0" name="process_info" type="int" enum="Physics2DServer.ProcessInfo" />
  664. <description>
  665. Returns information about the current state of the 2D physics engine. See [enum ProcessInfo] for a list of available states.
  666. </description>
  667. </method>
  668. <method name="groove_joint_create">
  669. <return type="RID" />
  670. <argument index="0" name="groove1_a" type="Vector2" />
  671. <argument index="1" name="groove2_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. Creates a groove joint between two bodies. If not specified, the bodies are assumed to be the joint itself.
  677. </description>
  678. </method>
  679. <method name="joint_get_param" qualifiers="const">
  680. <return type="float" />
  681. <argument index="0" name="joint" type="RID" />
  682. <argument index="1" name="param" type="int" enum="Physics2DServer.JointParam" />
  683. <description>
  684. Returns the value of a joint parameter.
  685. </description>
  686. </method>
  687. <method name="joint_get_type" qualifiers="const">
  688. <return type="int" enum="Physics2DServer.JointType" />
  689. <argument index="0" name="joint" type="RID" />
  690. <description>
  691. Returns a joint's type (see [enum JointType]).
  692. </description>
  693. </method>
  694. <method name="joint_set_param">
  695. <return type="void" />
  696. <argument index="0" name="joint" type="RID" />
  697. <argument index="1" name="param" type="int" enum="Physics2DServer.JointParam" />
  698. <argument index="2" name="value" type="float" />
  699. <description>
  700. Sets a joint parameter. See [enum JointParam] for a list of available parameters.
  701. </description>
  702. </method>
  703. <method name="line_shape_create">
  704. <return type="RID" />
  705. <description>
  706. </description>
  707. </method>
  708. <method name="pin_joint_create">
  709. <return type="RID" />
  710. <argument index="0" name="anchor" type="Vector2" />
  711. <argument index="1" name="body_a" type="RID" />
  712. <argument index="2" name="body_b" type="RID" />
  713. <description>
  714. Creates a pin joint between two bodies. If not specified, the second body is assumed to be the joint itself.
  715. </description>
  716. </method>
  717. <method name="ray_shape_create">
  718. <return type="RID" />
  719. <description>
  720. </description>
  721. </method>
  722. <method name="rectangle_shape_create">
  723. <return type="RID" />
  724. <description>
  725. </description>
  726. </method>
  727. <method name="segment_shape_create">
  728. <return type="RID" />
  729. <description>
  730. </description>
  731. </method>
  732. <method name="set_active">
  733. <return type="void" />
  734. <argument index="0" name="active" type="bool" />
  735. <description>
  736. Activates or deactivates the 2D physics engine.
  737. </description>
  738. </method>
  739. <method name="set_collision_iterations">
  740. <return type="void" />
  741. <argument index="0" name="iterations" type="int" />
  742. <description>
  743. 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].
  744. </description>
  745. </method>
  746. <method name="shape_get_data" qualifiers="const">
  747. <return type="Variant" />
  748. <argument index="0" name="shape" type="RID" />
  749. <description>
  750. Returns the shape data.
  751. </description>
  752. </method>
  753. <method name="shape_get_type" qualifiers="const">
  754. <return type="int" enum="Physics2DServer.ShapeType" />
  755. <argument index="0" name="shape" type="RID" />
  756. <description>
  757. Returns a shape's type (see [enum ShapeType]).
  758. </description>
  759. </method>
  760. <method name="shape_set_data">
  761. <return type="void" />
  762. <argument index="0" name="shape" type="RID" />
  763. <argument index="1" name="data" type="Variant" />
  764. <description>
  765. 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].
  766. </description>
  767. </method>
  768. <method name="space_create">
  769. <return type="RID" />
  770. <description>
  771. 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].
  772. </description>
  773. </method>
  774. <method name="space_get_direct_state">
  775. <return type="Physics2DDirectSpaceState" />
  776. <argument index="0" name="space" type="RID" />
  777. <description>
  778. Returns the state of a space, a [Physics2DDirectSpaceState]. This object can be used to make collision/intersection queries.
  779. </description>
  780. </method>
  781. <method name="space_get_param" qualifiers="const">
  782. <return type="float" />
  783. <argument index="0" name="space" type="RID" />
  784. <argument index="1" name="param" type="int" enum="Physics2DServer.SpaceParameter" />
  785. <description>
  786. Returns the value of a space parameter.
  787. </description>
  788. </method>
  789. <method name="space_is_active" qualifiers="const">
  790. <return type="bool" />
  791. <argument index="0" name="space" type="RID" />
  792. <description>
  793. Returns whether the space is active.
  794. </description>
  795. </method>
  796. <method name="space_set_active">
  797. <return type="void" />
  798. <argument index="0" name="space" type="RID" />
  799. <argument index="1" name="active" type="bool" />
  800. <description>
  801. Marks a space as active. It will not have an effect, unless it is assigned to an area or body.
  802. </description>
  803. </method>
  804. <method name="space_set_param">
  805. <return type="void" />
  806. <argument index="0" name="space" type="RID" />
  807. <argument index="1" name="param" type="int" enum="Physics2DServer.SpaceParameter" />
  808. <argument index="2" name="value" type="float" />
  809. <description>
  810. Sets the value for a space parameter. See [enum SpaceParameter] for a list of available parameters.
  811. </description>
  812. </method>
  813. </methods>
  814. <constants>
  815. <constant name="SPACE_PARAM_CONTACT_RECYCLE_RADIUS" value="0" enum="SpaceParameter">
  816. Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated.
  817. </constant>
  818. <constant name="SPACE_PARAM_CONTACT_MAX_SEPARATION" value="1" enum="SpaceParameter">
  819. Constant to set/get the maximum distance a shape can be from another before they are considered separated.
  820. </constant>
  821. <constant name="SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION" value="2" enum="SpaceParameter">
  822. Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision.
  823. </constant>
  824. <constant name="SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD" value="3" enum="SpaceParameter">
  825. 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.
  826. </constant>
  827. <constant name="SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD" value="4" enum="SpaceParameter">
  828. 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.
  829. </constant>
  830. <constant name="SPACE_PARAM_BODY_TIME_TO_SLEEP" value="5" enum="SpaceParameter">
  831. 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.
  832. </constant>
  833. <constant name="SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS" value="6" enum="SpaceParameter">
  834. 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.
  835. </constant>
  836. <constant name="SHAPE_LINE" value="0" enum="ShapeType">
  837. This is the constant for creating line shapes. A line shape is an infinite line with an origin point, and a normal. Thus, it can be used for front/behind checks.
  838. </constant>
  839. <constant name="SHAPE_RAY" value="1" enum="ShapeType">
  840. </constant>
  841. <constant name="SHAPE_SEGMENT" value="2" enum="ShapeType">
  842. This is the constant for creating segment shapes. A segment shape is a line from a point A to a point B. It can be checked for intersections.
  843. </constant>
  844. <constant name="SHAPE_CIRCLE" value="3" enum="ShapeType">
  845. 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.
  846. </constant>
  847. <constant name="SHAPE_RECTANGLE" value="4" enum="ShapeType">
  848. 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.
  849. </constant>
  850. <constant name="SHAPE_CAPSULE" value="5" enum="ShapeType">
  851. 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.
  852. </constant>
  853. <constant name="SHAPE_CONVEX_POLYGON" value="6" enum="ShapeType">
  854. 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.
  855. </constant>
  856. <constant name="SHAPE_CONCAVE_POLYGON" value="7" enum="ShapeType">
  857. 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.
  858. </constant>
  859. <constant name="SHAPE_CUSTOM" value="8" enum="ShapeType">
  860. This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
  861. </constant>
  862. <constant name="AREA_PARAM_GRAVITY" value="0" enum="AreaParameter">
  863. Constant to set/get gravity strength in an area.
  864. </constant>
  865. <constant name="AREA_PARAM_GRAVITY_VECTOR" value="1" enum="AreaParameter">
  866. Constant to set/get gravity vector/center in an area.
  867. </constant>
  868. <constant name="AREA_PARAM_GRAVITY_IS_POINT" value="2" enum="AreaParameter">
  869. Constant to set/get whether the gravity vector of an area is a direction, or a center point.
  870. </constant>
  871. <constant name="AREA_PARAM_GRAVITY_DISTANCE_SCALE" value="3" enum="AreaParameter">
  872. 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.
  873. </constant>
  874. <constant name="AREA_PARAM_GRAVITY_POINT_ATTENUATION" value="4" enum="AreaParameter">
  875. This constant was used to set/get the falloff factor for point gravity. It has been superseded by [constant AREA_PARAM_GRAVITY_DISTANCE_SCALE].
  876. </constant>
  877. <constant name="AREA_PARAM_LINEAR_DAMP" value="5" enum="AreaParameter">
  878. Constant to set/get the linear dampening factor of an area.
  879. </constant>
  880. <constant name="AREA_PARAM_ANGULAR_DAMP" value="6" enum="AreaParameter">
  881. Constant to set/get the angular dampening factor of an area.
  882. </constant>
  883. <constant name="AREA_PARAM_PRIORITY" value="7" enum="AreaParameter">
  884. Constant to set/get the priority (order of processing) of an area.
  885. </constant>
  886. <constant name="AREA_SPACE_OVERRIDE_DISABLED" value="0" enum="AreaSpaceOverrideMode">
  887. This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
  888. </constant>
  889. <constant name="AREA_SPACE_OVERRIDE_COMBINE" value="1" enum="AreaSpaceOverrideMode">
  890. 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.
  891. </constant>
  892. <constant name="AREA_SPACE_OVERRIDE_COMBINE_REPLACE" value="2" enum="AreaSpaceOverrideMode">
  893. 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.
  894. </constant>
  895. <constant name="AREA_SPACE_OVERRIDE_REPLACE" value="3" enum="AreaSpaceOverrideMode">
  896. This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
  897. </constant>
  898. <constant name="AREA_SPACE_OVERRIDE_REPLACE_COMBINE" value="4" enum="AreaSpaceOverrideMode">
  899. This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
  900. </constant>
  901. <constant name="BODY_MODE_STATIC" value="0" enum="BodyMode">
  902. Constant for static bodies.
  903. </constant>
  904. <constant name="BODY_MODE_KINEMATIC" value="1" enum="BodyMode">
  905. Constant for kinematic bodies.
  906. </constant>
  907. <constant name="BODY_MODE_RIGID" value="2" enum="BodyMode">
  908. Constant for rigid bodies.
  909. </constant>
  910. <constant name="BODY_MODE_CHARACTER" value="3" enum="BodyMode">
  911. Constant for rigid bodies in character mode. In this mode, a body can not rotate, and only its linear velocity is affected by physics.
  912. </constant>
  913. <constant name="BODY_PARAM_BOUNCE" value="0" enum="BodyParameter">
  914. Constant to set/get a body's bounce factor.
  915. </constant>
  916. <constant name="BODY_PARAM_FRICTION" value="1" enum="BodyParameter">
  917. Constant to set/get a body's friction.
  918. </constant>
  919. <constant name="BODY_PARAM_MASS" value="2" enum="BodyParameter">
  920. Constant to set/get a body's mass.
  921. </constant>
  922. <constant name="BODY_PARAM_INERTIA" value="3" enum="BodyParameter">
  923. Constant to set/get a body's inertia.
  924. </constant>
  925. <constant name="BODY_PARAM_GRAVITY_SCALE" value="4" enum="BodyParameter">
  926. Constant to set/get a body's gravity multiplier.
  927. </constant>
  928. <constant name="BODY_PARAM_LINEAR_DAMP" value="5" enum="BodyParameter">
  929. Constant to set/get a body's linear dampening factor.
  930. </constant>
  931. <constant name="BODY_PARAM_ANGULAR_DAMP" value="6" enum="BodyParameter">
  932. Constant to set/get a body's angular dampening factor.
  933. </constant>
  934. <constant name="BODY_PARAM_MAX" value="7" enum="BodyParameter">
  935. Represents the size of the [enum BodyParameter] enum.
  936. </constant>
  937. <constant name="BODY_STATE_TRANSFORM" value="0" enum="BodyState">
  938. Constant to set/get the current transform matrix of the body.
  939. </constant>
  940. <constant name="BODY_STATE_LINEAR_VELOCITY" value="1" enum="BodyState">
  941. Constant to set/get the current linear velocity of the body.
  942. </constant>
  943. <constant name="BODY_STATE_ANGULAR_VELOCITY" value="2" enum="BodyState">
  944. Constant to set/get the current angular velocity of the body.
  945. </constant>
  946. <constant name="BODY_STATE_SLEEPING" value="3" enum="BodyState">
  947. Constant to sleep/wake up a body, or to get whether it is sleeping.
  948. </constant>
  949. <constant name="BODY_STATE_CAN_SLEEP" value="4" enum="BodyState">
  950. Constant to set/get whether the body can sleep.
  951. </constant>
  952. <constant name="JOINT_PIN" value="0" enum="JointType">
  953. Constant to create pin joints.
  954. </constant>
  955. <constant name="JOINT_GROOVE" value="1" enum="JointType">
  956. Constant to create groove joints.
  957. </constant>
  958. <constant name="JOINT_DAMPED_SPRING" value="2" enum="JointType">
  959. Constant to create damped spring joints.
  960. </constant>
  961. <constant name="JOINT_PARAM_BIAS" value="0" enum="JointParam">
  962. </constant>
  963. <constant name="JOINT_PARAM_MAX_BIAS" value="1" enum="JointParam">
  964. </constant>
  965. <constant name="JOINT_PARAM_MAX_FORCE" value="2" enum="JointParam">
  966. </constant>
  967. <constant name="DAMPED_STRING_REST_LENGTH" value="0" enum="DampedStringParam">
  968. Sets the resting length of the spring joint. The joint will always try to go to back this length when pulled apart.
  969. </constant>
  970. <constant name="DAMPED_STRING_STIFFNESS" value="1" enum="DampedStringParam">
  971. Sets the stiffness of the spring joint. The joint applies a force equal to the stiffness times the distance from its resting length.
  972. </constant>
  973. <constant name="DAMPED_STRING_DAMPING" value="2" enum="DampedStringParam">
  974. 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).
  975. </constant>
  976. <constant name="CCD_MODE_DISABLED" value="0" enum="CCDMode">
  977. Disables continuous collision detection. This is the fastest way to detect body collisions, but can miss small, fast-moving objects.
  978. </constant>
  979. <constant name="CCD_MODE_CAST_RAY" value="1" enum="CCDMode">
  980. Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise.
  981. </constant>
  982. <constant name="CCD_MODE_CAST_SHAPE" value="2" enum="CCDMode">
  983. Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise.
  984. </constant>
  985. <constant name="AREA_BODY_ADDED" value="0" enum="AreaBodyStatus">
  986. The value of the first parameter and area callback function receives, when an object enters one of its shapes.
  987. </constant>
  988. <constant name="AREA_BODY_REMOVED" value="1" enum="AreaBodyStatus">
  989. The value of the first parameter and area callback function receives, when an object exits one of its shapes.
  990. </constant>
  991. <constant name="INFO_ACTIVE_OBJECTS" value="0" enum="ProcessInfo">
  992. Constant to get the number of objects that are not sleeping.
  993. </constant>
  994. <constant name="INFO_COLLISION_PAIRS" value="1" enum="ProcessInfo">
  995. Constant to get the number of possible collisions.
  996. </constant>
  997. <constant name="INFO_ISLAND_COUNT" value="2" enum="ProcessInfo">
  998. Constant to get the number of space regions where a collision could occur.
  999. </constant>
  1000. </constants>
  1001. </class>