class_physicsserver2d.rst 175 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.1/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.1/doc/classes/PhysicsServer2D.xml.
  6. .. _class_PhysicsServer2D:
  7. PhysicsServer2D
  8. ===============
  9. **Inherits:** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`PhysicsServer2DExtension<class_PhysicsServer2DExtension>`
  11. A server interface for low-level 2D physics access.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. PhysicsServer2D is the server responsible for all 2D physics. It can directly create and manipulate all physics objects:
  16. - A *space* is a self-contained world for a physics simulation. It contains bodies, areas, and joints. Its state can be queried for collision and intersection information, and several parameters of the simulation can be modified.
  17. - A *shape* is a geometric shape such as a circle, a rectangle, a capsule, or a polygon. It can be used for collision detection by adding it to a body/area, possibly with an extra transformation relative to the body/area's origin. Bodies/areas can have multiple (transformed) shapes added to them, and a single shape can be added to bodies/areas multiple times with different local transformations.
  18. - A *body* is a physical object which can be in static, kinematic, or rigid mode. Its state (such as position and velocity) can be queried and updated. A force integration callback can be set to customize the body's physics.
  19. - An *area* is a region in space which can be used to detect bodies and areas entering and exiting it. A body monitoring callback can be set to report entering/exiting body shapes, and similarly an area monitoring callback can be set. Gravity and damping can be overridden within the area by setting area parameters.
  20. - A *joint* is a constraint, either between two bodies or on one body relative to a point. Parameters such as the joint bias and the rest length of a spring joint can be adjusted.
  21. Physics objects in **PhysicsServer2D** may be created and manipulated independently; they do not have to be tied to nodes in the scene tree.
  22. \ **Note:** All the 2D physics nodes use the physics server internally. Adding a physics node to the scene tree will cause a corresponding physics object to be created in the physics server. A rigid body node registers a callback that updates the node's transform with the transform of the respective body object in the physics server (every physics update). An area node registers a callback to inform the area node about overlaps with the respective area object in the physics server. The raycast node queries the direct state of the relevant space in the physics server.
  23. .. rst-class:: classref-reftable-group
  24. Methods
  25. -------
  26. .. table::
  27. :widths: auto
  28. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`area_add_shape<class_PhysicsServer2D_method_area_add_shape>` **(** :ref:`RID<class_RID>` area, :ref:`RID<class_RID>` shape, :ref:`Transform2D<class_Transform2D>` transform=Transform2D(1, 0, 0, 1, 0, 0), :ref:`bool<class_bool>` disabled=false **)** |
  30. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`area_attach_canvas_instance_id<class_PhysicsServer2D_method_area_attach_canvas_instance_id>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` id **)** |
  32. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`area_attach_object_instance_id<class_PhysicsServer2D_method_area_attach_object_instance_id>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` id **)** |
  34. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`area_clear_shapes<class_PhysicsServer2D_method_area_clear_shapes>` **(** :ref:`RID<class_RID>` area **)** |
  36. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`RID<class_RID>` | :ref:`area_create<class_PhysicsServer2D_method_area_create>` **(** **)** |
  38. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`area_get_canvas_instance_id<class_PhysicsServer2D_method_area_get_canvas_instance_id>` **(** :ref:`RID<class_RID>` area **)** |const| |
  40. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`area_get_collision_layer<class_PhysicsServer2D_method_area_get_collision_layer>` **(** :ref:`RID<class_RID>` area **)** |const| |
  42. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`area_get_collision_mask<class_PhysicsServer2D_method_area_get_collision_mask>` **(** :ref:`RID<class_RID>` area **)** |const| |
  44. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`int<class_int>` | :ref:`area_get_object_instance_id<class_PhysicsServer2D_method_area_get_object_instance_id>` **(** :ref:`RID<class_RID>` area **)** |const| |
  46. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Variant<class_Variant>` | :ref:`area_get_param<class_PhysicsServer2D_method_area_get_param>` **(** :ref:`RID<class_RID>` area, :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` param **)** |const| |
  48. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`RID<class_RID>` | :ref:`area_get_shape<class_PhysicsServer2D_method_area_get_shape>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx **)** |const| |
  50. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`area_get_shape_count<class_PhysicsServer2D_method_area_get_shape_count>` **(** :ref:`RID<class_RID>` area **)** |const| |
  52. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Transform2D<class_Transform2D>` | :ref:`area_get_shape_transform<class_PhysicsServer2D_method_area_get_shape_transform>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx **)** |const| |
  54. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`RID<class_RID>` | :ref:`area_get_space<class_PhysicsServer2D_method_area_get_space>` **(** :ref:`RID<class_RID>` area **)** |const| |
  56. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Transform2D<class_Transform2D>` | :ref:`area_get_transform<class_PhysicsServer2D_method_area_get_transform>` **(** :ref:`RID<class_RID>` area **)** |const| |
  58. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`area_remove_shape<class_PhysicsServer2D_method_area_remove_shape>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx **)** |
  60. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`area_set_area_monitor_callback<class_PhysicsServer2D_method_area_set_area_monitor_callback>` **(** :ref:`RID<class_RID>` area, :ref:`Callable<class_Callable>` callback **)** |
  62. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`area_set_collision_layer<class_PhysicsServer2D_method_area_set_collision_layer>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` layer **)** |
  64. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`area_set_collision_mask<class_PhysicsServer2D_method_area_set_collision_mask>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` mask **)** |
  66. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`area_set_monitor_callback<class_PhysicsServer2D_method_area_set_monitor_callback>` **(** :ref:`RID<class_RID>` area, :ref:`Callable<class_Callable>` callback **)** |
  68. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`area_set_monitorable<class_PhysicsServer2D_method_area_set_monitorable>` **(** :ref:`RID<class_RID>` area, :ref:`bool<class_bool>` monitorable **)** |
  70. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`area_set_param<class_PhysicsServer2D_method_area_set_param>` **(** :ref:`RID<class_RID>` area, :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` param, :ref:`Variant<class_Variant>` value **)** |
  72. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`area_set_shape<class_PhysicsServer2D_method_area_set_shape>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx, :ref:`RID<class_RID>` shape **)** |
  74. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`area_set_shape_disabled<class_PhysicsServer2D_method_area_set_shape_disabled>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` disabled **)** |
  76. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`area_set_shape_transform<class_PhysicsServer2D_method_area_set_shape_transform>` **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx, :ref:`Transform2D<class_Transform2D>` transform **)** |
  78. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`area_set_space<class_PhysicsServer2D_method_area_set_space>` **(** :ref:`RID<class_RID>` area, :ref:`RID<class_RID>` space **)** |
  80. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`area_set_transform<class_PhysicsServer2D_method_area_set_transform>` **(** :ref:`RID<class_RID>` area, :ref:`Transform2D<class_Transform2D>` transform **)** |
  82. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`body_add_collision_exception<class_PhysicsServer2D_method_body_add_collision_exception>` **(** :ref:`RID<class_RID>` body, :ref:`RID<class_RID>` excepted_body **)** |
  84. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`body_add_constant_central_force<class_PhysicsServer2D_method_body_add_constant_central_force>` **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force **)** |
  86. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`body_add_constant_force<class_PhysicsServer2D_method_body_add_constant_force>` **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force, :ref:`Vector2<class_Vector2>` position=Vector2(0, 0) **)** |
  88. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`body_add_constant_torque<class_PhysicsServer2D_method_body_add_constant_torque>` **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` torque **)** |
  90. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`body_add_shape<class_PhysicsServer2D_method_body_add_shape>` **(** :ref:`RID<class_RID>` body, :ref:`RID<class_RID>` shape, :ref:`Transform2D<class_Transform2D>` transform=Transform2D(1, 0, 0, 1, 0, 0), :ref:`bool<class_bool>` disabled=false **)** |
  92. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`body_apply_central_force<class_PhysicsServer2D_method_body_apply_central_force>` **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force **)** |
  94. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`body_apply_central_impulse<class_PhysicsServer2D_method_body_apply_central_impulse>` **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` impulse **)** |
  96. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`body_apply_force<class_PhysicsServer2D_method_body_apply_force>` **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force, :ref:`Vector2<class_Vector2>` position=Vector2(0, 0) **)** |
  98. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`body_apply_impulse<class_PhysicsServer2D_method_body_apply_impulse>` **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` impulse, :ref:`Vector2<class_Vector2>` position=Vector2(0, 0) **)** |
  100. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`body_apply_torque<class_PhysicsServer2D_method_body_apply_torque>` **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` torque **)** |
  102. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`body_apply_torque_impulse<class_PhysicsServer2D_method_body_apply_torque_impulse>` **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` impulse **)** |
  104. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`body_attach_canvas_instance_id<class_PhysicsServer2D_method_body_attach_canvas_instance_id>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` id **)** |
  106. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`body_attach_object_instance_id<class_PhysicsServer2D_method_body_attach_object_instance_id>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` id **)** |
  108. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | void | :ref:`body_clear_shapes<class_PhysicsServer2D_method_body_clear_shapes>` **(** :ref:`RID<class_RID>` body **)** |
  110. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | :ref:`RID<class_RID>` | :ref:`body_create<class_PhysicsServer2D_method_body_create>` **(** **)** |
  112. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`int<class_int>` | :ref:`body_get_canvas_instance_id<class_PhysicsServer2D_method_body_get_canvas_instance_id>` **(** :ref:`RID<class_RID>` body **)** |const| |
  114. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`int<class_int>` | :ref:`body_get_collision_layer<class_PhysicsServer2D_method_body_get_collision_layer>` **(** :ref:`RID<class_RID>` body **)** |const| |
  116. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`int<class_int>` | :ref:`body_get_collision_mask<class_PhysicsServer2D_method_body_get_collision_mask>` **(** :ref:`RID<class_RID>` body **)** |const| |
  118. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`float<class_float>` | :ref:`body_get_collision_priority<class_PhysicsServer2D_method_body_get_collision_priority>` **(** :ref:`RID<class_RID>` body **)** |const| |
  120. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`Vector2<class_Vector2>` | :ref:`body_get_constant_force<class_PhysicsServer2D_method_body_get_constant_force>` **(** :ref:`RID<class_RID>` body **)** |const| |
  122. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`float<class_float>` | :ref:`body_get_constant_torque<class_PhysicsServer2D_method_body_get_constant_torque>` **(** :ref:`RID<class_RID>` body **)** |const| |
  124. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | :ref:`CCDMode<enum_PhysicsServer2D_CCDMode>` | :ref:`body_get_continuous_collision_detection_mode<class_PhysicsServer2D_method_body_get_continuous_collision_detection_mode>` **(** :ref:`RID<class_RID>` body **)** |const| |
  126. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | :ref:`PhysicsDirectBodyState2D<class_PhysicsDirectBodyState2D>` | :ref:`body_get_direct_state<class_PhysicsServer2D_method_body_get_direct_state>` **(** :ref:`RID<class_RID>` body **)** |
  128. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | :ref:`int<class_int>` | :ref:`body_get_max_contacts_reported<class_PhysicsServer2D_method_body_get_max_contacts_reported>` **(** :ref:`RID<class_RID>` body **)** |const| |
  130. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>` | :ref:`body_get_mode<class_PhysicsServer2D_method_body_get_mode>` **(** :ref:`RID<class_RID>` body **)** |const| |
  132. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | :ref:`int<class_int>` | :ref:`body_get_object_instance_id<class_PhysicsServer2D_method_body_get_object_instance_id>` **(** :ref:`RID<class_RID>` body **)** |const| |
  134. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | :ref:`Variant<class_Variant>` | :ref:`body_get_param<class_PhysicsServer2D_method_body_get_param>` **(** :ref:`RID<class_RID>` body, :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` param **)** |const| |
  136. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | :ref:`RID<class_RID>` | :ref:`body_get_shape<class_PhysicsServer2D_method_body_get_shape>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx **)** |const| |
  138. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | :ref:`int<class_int>` | :ref:`body_get_shape_count<class_PhysicsServer2D_method_body_get_shape_count>` **(** :ref:`RID<class_RID>` body **)** |const| |
  140. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | :ref:`Transform2D<class_Transform2D>` | :ref:`body_get_shape_transform<class_PhysicsServer2D_method_body_get_shape_transform>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx **)** |const| |
  142. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | :ref:`RID<class_RID>` | :ref:`body_get_space<class_PhysicsServer2D_method_body_get_space>` **(** :ref:`RID<class_RID>` body **)** |const| |
  144. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`Variant<class_Variant>` | :ref:`body_get_state<class_PhysicsServer2D_method_body_get_state>` **(** :ref:`RID<class_RID>` body, :ref:`BodyState<enum_PhysicsServer2D_BodyState>` state **)** |const| |
  146. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | :ref:`bool<class_bool>` | :ref:`body_is_omitting_force_integration<class_PhysicsServer2D_method_body_is_omitting_force_integration>` **(** :ref:`RID<class_RID>` body **)** |const| |
  148. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. | void | :ref:`body_remove_collision_exception<class_PhysicsServer2D_method_body_remove_collision_exception>` **(** :ref:`RID<class_RID>` body, :ref:`RID<class_RID>` excepted_body **)** |
  150. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  151. | void | :ref:`body_remove_shape<class_PhysicsServer2D_method_body_remove_shape>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx **)** |
  152. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  153. | void | :ref:`body_reset_mass_properties<class_PhysicsServer2D_method_body_reset_mass_properties>` **(** :ref:`RID<class_RID>` body **)** |
  154. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  155. | void | :ref:`body_set_axis_velocity<class_PhysicsServer2D_method_body_set_axis_velocity>` **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` axis_velocity **)** |
  156. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  157. | void | :ref:`body_set_collision_layer<class_PhysicsServer2D_method_body_set_collision_layer>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` layer **)** |
  158. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  159. | void | :ref:`body_set_collision_mask<class_PhysicsServer2D_method_body_set_collision_mask>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` mask **)** |
  160. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  161. | void | :ref:`body_set_collision_priority<class_PhysicsServer2D_method_body_set_collision_priority>` **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` priority **)** |
  162. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  163. | void | :ref:`body_set_constant_force<class_PhysicsServer2D_method_body_set_constant_force>` **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force **)** |
  164. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  165. | void | :ref:`body_set_constant_torque<class_PhysicsServer2D_method_body_set_constant_torque>` **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` torque **)** |
  166. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  167. | void | :ref:`body_set_continuous_collision_detection_mode<class_PhysicsServer2D_method_body_set_continuous_collision_detection_mode>` **(** :ref:`RID<class_RID>` body, :ref:`CCDMode<enum_PhysicsServer2D_CCDMode>` mode **)** |
  168. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  169. | void | :ref:`body_set_force_integration_callback<class_PhysicsServer2D_method_body_set_force_integration_callback>` **(** :ref:`RID<class_RID>` body, :ref:`Callable<class_Callable>` callable, :ref:`Variant<class_Variant>` userdata=null **)** |
  170. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  171. | void | :ref:`body_set_max_contacts_reported<class_PhysicsServer2D_method_body_set_max_contacts_reported>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` amount **)** |
  172. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  173. | void | :ref:`body_set_mode<class_PhysicsServer2D_method_body_set_mode>` **(** :ref:`RID<class_RID>` body, :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>` mode **)** |
  174. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  175. | void | :ref:`body_set_omit_force_integration<class_PhysicsServer2D_method_body_set_omit_force_integration>` **(** :ref:`RID<class_RID>` body, :ref:`bool<class_bool>` enable **)** |
  176. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  177. | void | :ref:`body_set_param<class_PhysicsServer2D_method_body_set_param>` **(** :ref:`RID<class_RID>` body, :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` param, :ref:`Variant<class_Variant>` value **)** |
  178. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  179. | void | :ref:`body_set_shape<class_PhysicsServer2D_method_body_set_shape>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx, :ref:`RID<class_RID>` shape **)** |
  180. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  181. | void | :ref:`body_set_shape_as_one_way_collision<class_PhysicsServer2D_method_body_set_shape_as_one_way_collision>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` enable, :ref:`float<class_float>` margin **)** |
  182. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  183. | void | :ref:`body_set_shape_disabled<class_PhysicsServer2D_method_body_set_shape_disabled>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` disabled **)** |
  184. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  185. | void | :ref:`body_set_shape_transform<class_PhysicsServer2D_method_body_set_shape_transform>` **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx, :ref:`Transform2D<class_Transform2D>` transform **)** |
  186. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  187. | void | :ref:`body_set_space<class_PhysicsServer2D_method_body_set_space>` **(** :ref:`RID<class_RID>` body, :ref:`RID<class_RID>` space **)** |
  188. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  189. | void | :ref:`body_set_state<class_PhysicsServer2D_method_body_set_state>` **(** :ref:`RID<class_RID>` body, :ref:`BodyState<enum_PhysicsServer2D_BodyState>` state, :ref:`Variant<class_Variant>` value **)** |
  190. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  191. | :ref:`bool<class_bool>` | :ref:`body_test_motion<class_PhysicsServer2D_method_body_test_motion>` **(** :ref:`RID<class_RID>` body, :ref:`PhysicsTestMotionParameters2D<class_PhysicsTestMotionParameters2D>` parameters, :ref:`PhysicsTestMotionResult2D<class_PhysicsTestMotionResult2D>` result=null **)** |
  192. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  193. | :ref:`RID<class_RID>` | :ref:`capsule_shape_create<class_PhysicsServer2D_method_capsule_shape_create>` **(** **)** |
  194. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  195. | :ref:`RID<class_RID>` | :ref:`circle_shape_create<class_PhysicsServer2D_method_circle_shape_create>` **(** **)** |
  196. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  197. | :ref:`RID<class_RID>` | :ref:`concave_polygon_shape_create<class_PhysicsServer2D_method_concave_polygon_shape_create>` **(** **)** |
  198. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  199. | :ref:`RID<class_RID>` | :ref:`convex_polygon_shape_create<class_PhysicsServer2D_method_convex_polygon_shape_create>` **(** **)** |
  200. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  201. | :ref:`float<class_float>` | :ref:`damped_spring_joint_get_param<class_PhysicsServer2D_method_damped_spring_joint_get_param>` **(** :ref:`RID<class_RID>` joint, :ref:`DampedSpringParam<enum_PhysicsServer2D_DampedSpringParam>` param **)** |const| |
  202. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  203. | void | :ref:`damped_spring_joint_set_param<class_PhysicsServer2D_method_damped_spring_joint_set_param>` **(** :ref:`RID<class_RID>` joint, :ref:`DampedSpringParam<enum_PhysicsServer2D_DampedSpringParam>` param, :ref:`float<class_float>` value **)** |
  204. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  205. | void | :ref:`free_rid<class_PhysicsServer2D_method_free_rid>` **(** :ref:`RID<class_RID>` rid **)** |
  206. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  207. | :ref:`int<class_int>` | :ref:`get_process_info<class_PhysicsServer2D_method_get_process_info>` **(** :ref:`ProcessInfo<enum_PhysicsServer2D_ProcessInfo>` process_info **)** |
  208. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  209. | void | :ref:`joint_clear<class_PhysicsServer2D_method_joint_clear>` **(** :ref:`RID<class_RID>` joint **)** |
  210. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  211. | :ref:`RID<class_RID>` | :ref:`joint_create<class_PhysicsServer2D_method_joint_create>` **(** **)** |
  212. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  213. | void | :ref:`joint_disable_collisions_between_bodies<class_PhysicsServer2D_method_joint_disable_collisions_between_bodies>` **(** :ref:`RID<class_RID>` joint, :ref:`bool<class_bool>` disable **)** |
  214. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  215. | :ref:`float<class_float>` | :ref:`joint_get_param<class_PhysicsServer2D_method_joint_get_param>` **(** :ref:`RID<class_RID>` joint, :ref:`JointParam<enum_PhysicsServer2D_JointParam>` param **)** |const| |
  216. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  217. | :ref:`JointType<enum_PhysicsServer2D_JointType>` | :ref:`joint_get_type<class_PhysicsServer2D_method_joint_get_type>` **(** :ref:`RID<class_RID>` joint **)** |const| |
  218. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  219. | :ref:`bool<class_bool>` | :ref:`joint_is_disabled_collisions_between_bodies<class_PhysicsServer2D_method_joint_is_disabled_collisions_between_bodies>` **(** :ref:`RID<class_RID>` joint **)** |const| |
  220. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  221. | void | :ref:`joint_make_damped_spring<class_PhysicsServer2D_method_joint_make_damped_spring>` **(** :ref:`RID<class_RID>` joint, :ref:`Vector2<class_Vector2>` anchor_a, :ref:`Vector2<class_Vector2>` anchor_b, :ref:`RID<class_RID>` body_a, :ref:`RID<class_RID>` body_b=RID() **)** |
  222. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  223. | void | :ref:`joint_make_groove<class_PhysicsServer2D_method_joint_make_groove>` **(** :ref:`RID<class_RID>` joint, :ref:`Vector2<class_Vector2>` groove1_a, :ref:`Vector2<class_Vector2>` groove2_a, :ref:`Vector2<class_Vector2>` anchor_b, :ref:`RID<class_RID>` body_a=RID(), :ref:`RID<class_RID>` body_b=RID() **)** |
  224. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  225. | void | :ref:`joint_make_pin<class_PhysicsServer2D_method_joint_make_pin>` **(** :ref:`RID<class_RID>` joint, :ref:`Vector2<class_Vector2>` anchor, :ref:`RID<class_RID>` body_a, :ref:`RID<class_RID>` body_b=RID() **)** |
  226. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  227. | void | :ref:`joint_set_param<class_PhysicsServer2D_method_joint_set_param>` **(** :ref:`RID<class_RID>` joint, :ref:`JointParam<enum_PhysicsServer2D_JointParam>` param, :ref:`float<class_float>` value **)** |
  228. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  229. | :ref:`float<class_float>` | :ref:`pin_joint_get_param<class_PhysicsServer2D_method_pin_joint_get_param>` **(** :ref:`RID<class_RID>` joint, :ref:`PinJointParam<enum_PhysicsServer2D_PinJointParam>` param **)** |const| |
  230. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  231. | void | :ref:`pin_joint_set_param<class_PhysicsServer2D_method_pin_joint_set_param>` **(** :ref:`RID<class_RID>` joint, :ref:`PinJointParam<enum_PhysicsServer2D_PinJointParam>` param, :ref:`float<class_float>` value **)** |
  232. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  233. | :ref:`RID<class_RID>` | :ref:`rectangle_shape_create<class_PhysicsServer2D_method_rectangle_shape_create>` **(** **)** |
  234. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  235. | :ref:`RID<class_RID>` | :ref:`segment_shape_create<class_PhysicsServer2D_method_segment_shape_create>` **(** **)** |
  236. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  237. | :ref:`RID<class_RID>` | :ref:`separation_ray_shape_create<class_PhysicsServer2D_method_separation_ray_shape_create>` **(** **)** |
  238. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  239. | void | :ref:`set_active<class_PhysicsServer2D_method_set_active>` **(** :ref:`bool<class_bool>` active **)** |
  240. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  241. | :ref:`Variant<class_Variant>` | :ref:`shape_get_data<class_PhysicsServer2D_method_shape_get_data>` **(** :ref:`RID<class_RID>` shape **)** |const| |
  242. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  243. | :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` | :ref:`shape_get_type<class_PhysicsServer2D_method_shape_get_type>` **(** :ref:`RID<class_RID>` shape **)** |const| |
  244. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  245. | void | :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` **(** :ref:`RID<class_RID>` shape, :ref:`Variant<class_Variant>` data **)** |
  246. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  247. | :ref:`RID<class_RID>` | :ref:`space_create<class_PhysicsServer2D_method_space_create>` **(** **)** |
  248. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  249. | :ref:`PhysicsDirectSpaceState2D<class_PhysicsDirectSpaceState2D>` | :ref:`space_get_direct_state<class_PhysicsServer2D_method_space_get_direct_state>` **(** :ref:`RID<class_RID>` space **)** |
  250. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  251. | :ref:`float<class_float>` | :ref:`space_get_param<class_PhysicsServer2D_method_space_get_param>` **(** :ref:`RID<class_RID>` space, :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` param **)** |const| |
  252. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  253. | :ref:`bool<class_bool>` | :ref:`space_is_active<class_PhysicsServer2D_method_space_is_active>` **(** :ref:`RID<class_RID>` space **)** |const| |
  254. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  255. | void | :ref:`space_set_active<class_PhysicsServer2D_method_space_set_active>` **(** :ref:`RID<class_RID>` space, :ref:`bool<class_bool>` active **)** |
  256. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  257. | void | :ref:`space_set_param<class_PhysicsServer2D_method_space_set_param>` **(** :ref:`RID<class_RID>` space, :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` param, :ref:`float<class_float>` value **)** |
  258. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  259. | :ref:`RID<class_RID>` | :ref:`world_boundary_shape_create<class_PhysicsServer2D_method_world_boundary_shape_create>` **(** **)** |
  260. +-------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  261. .. rst-class:: classref-section-separator
  262. ----
  263. .. rst-class:: classref-descriptions-group
  264. Enumerations
  265. ------------
  266. .. _enum_PhysicsServer2D_SpaceParameter:
  267. .. rst-class:: classref-enumeration
  268. enum **SpaceParameter**:
  269. .. _class_PhysicsServer2D_constant_SPACE_PARAM_CONTACT_RECYCLE_RADIUS:
  270. .. rst-class:: classref-enumeration-constant
  271. :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` **SPACE_PARAM_CONTACT_RECYCLE_RADIUS** = ``0``
  272. Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated. The default value of this parameter is :ref:`ProjectSettings.physics/2d/solver/contact_recycle_radius<class_ProjectSettings_property_physics/2d/solver/contact_recycle_radius>`.
  273. .. _class_PhysicsServer2D_constant_SPACE_PARAM_CONTACT_MAX_SEPARATION:
  274. .. rst-class:: classref-enumeration-constant
  275. :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` **SPACE_PARAM_CONTACT_MAX_SEPARATION** = ``1``
  276. Constant to set/get the maximum distance a shape can be from another before they are considered separated and the contact is discarded. The default value of this parameter is :ref:`ProjectSettings.physics/2d/solver/contact_max_separation<class_ProjectSettings_property_physics/2d/solver/contact_max_separation>`.
  277. .. _class_PhysicsServer2D_constant_SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION:
  278. .. rst-class:: classref-enumeration-constant
  279. :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` **SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION** = ``2``
  280. Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision. The default value of this parameter is :ref:`ProjectSettings.physics/2d/solver/contact_max_allowed_penetration<class_ProjectSettings_property_physics/2d/solver/contact_max_allowed_penetration>`.
  281. .. _class_PhysicsServer2D_constant_SPACE_PARAM_CONTACT_DEFAULT_BIAS:
  282. .. rst-class:: classref-enumeration-constant
  283. :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` **SPACE_PARAM_CONTACT_DEFAULT_BIAS** = ``3``
  284. Constant to set/get the default solver bias for all physics contacts. A solver bias is a factor controlling how much two objects "rebound", after overlapping, to avoid leaving them in that state because of numerical imprecision. The default value of this parameter is :ref:`ProjectSettings.physics/2d/solver/default_contact_bias<class_ProjectSettings_property_physics/2d/solver/default_contact_bias>`.
  285. .. _class_PhysicsServer2D_constant_SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD:
  286. .. rst-class:: classref-enumeration-constant
  287. :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` **SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD** = ``4``
  288. 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. The default value of this parameter is :ref:`ProjectSettings.physics/2d/sleep_threshold_linear<class_ProjectSettings_property_physics/2d/sleep_threshold_linear>`.
  289. .. _class_PhysicsServer2D_constant_SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD:
  290. .. rst-class:: classref-enumeration-constant
  291. :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` **SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD** = ``5``
  292. 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. The default value of this parameter is :ref:`ProjectSettings.physics/2d/sleep_threshold_angular<class_ProjectSettings_property_physics/2d/sleep_threshold_angular>`.
  293. .. _class_PhysicsServer2D_constant_SPACE_PARAM_BODY_TIME_TO_SLEEP:
  294. .. rst-class:: classref-enumeration-constant
  295. :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` **SPACE_PARAM_BODY_TIME_TO_SLEEP** = ``6``
  296. 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. The default value of this parameter is :ref:`ProjectSettings.physics/2d/time_before_sleep<class_ProjectSettings_property_physics/2d/time_before_sleep>`.
  297. .. _class_PhysicsServer2D_constant_SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS:
  298. .. rst-class:: classref-enumeration-constant
  299. :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` **SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS** = ``7``
  300. 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. The default value of this parameter is :ref:`ProjectSettings.physics/2d/solver/default_constraint_bias<class_ProjectSettings_property_physics/2d/solver/default_constraint_bias>`.
  301. .. _class_PhysicsServer2D_constant_SPACE_PARAM_SOLVER_ITERATIONS:
  302. .. rst-class:: classref-enumeration-constant
  303. :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` **SPACE_PARAM_SOLVER_ITERATIONS** = ``8``
  304. Constant to set/get the number of solver iterations for all contacts and constraints. The greater the number of iterations, the more accurate the collisions will be. However, a greater number of iterations requires more CPU power, which can decrease performance. The default value of this parameter is :ref:`ProjectSettings.physics/2d/solver/solver_iterations<class_ProjectSettings_property_physics/2d/solver/solver_iterations>`.
  305. .. rst-class:: classref-item-separator
  306. ----
  307. .. _enum_PhysicsServer2D_ShapeType:
  308. .. rst-class:: classref-enumeration
  309. enum **ShapeType**:
  310. .. _class_PhysicsServer2D_constant_SHAPE_WORLD_BOUNDARY:
  311. .. rst-class:: classref-enumeration-constant
  312. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **SHAPE_WORLD_BOUNDARY** = ``0``
  313. This is the constant for creating world boundary shapes. A world boundary shape is an *infinite* line with an origin point, and a normal. Thus, it can be used for front/behind checks.
  314. .. _class_PhysicsServer2D_constant_SHAPE_SEPARATION_RAY:
  315. .. rst-class:: classref-enumeration-constant
  316. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **SHAPE_SEPARATION_RAY** = ``1``
  317. 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.
  318. .. _class_PhysicsServer2D_constant_SHAPE_SEGMENT:
  319. .. rst-class:: classref-enumeration-constant
  320. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **SHAPE_SEGMENT** = ``2``
  321. This is the constant for creating segment shapes. A segment shape is a *finite* line from a point A to a point B. It can be checked for intersections.
  322. .. _class_PhysicsServer2D_constant_SHAPE_CIRCLE:
  323. .. rst-class:: classref-enumeration-constant
  324. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **SHAPE_CIRCLE** = ``3``
  325. 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.
  326. .. _class_PhysicsServer2D_constant_SHAPE_RECTANGLE:
  327. .. rst-class:: classref-enumeration-constant
  328. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **SHAPE_RECTANGLE** = ``4``
  329. 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.
  330. .. _class_PhysicsServer2D_constant_SHAPE_CAPSULE:
  331. .. rst-class:: classref-enumeration-constant
  332. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **SHAPE_CAPSULE** = ``5``
  333. 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.
  334. .. _class_PhysicsServer2D_constant_SHAPE_CONVEX_POLYGON:
  335. .. rst-class:: classref-enumeration-constant
  336. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **SHAPE_CONVEX_POLYGON** = ``6``
  337. 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.
  338. .. _class_PhysicsServer2D_constant_SHAPE_CONCAVE_POLYGON:
  339. .. rst-class:: classref-enumeration-constant
  340. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **SHAPE_CONCAVE_POLYGON** = ``7``
  341. 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.
  342. .. _class_PhysicsServer2D_constant_SHAPE_CUSTOM:
  343. .. rst-class:: classref-enumeration-constant
  344. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **SHAPE_CUSTOM** = ``8``
  345. This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
  346. .. rst-class:: classref-item-separator
  347. ----
  348. .. _enum_PhysicsServer2D_AreaParameter:
  349. .. rst-class:: classref-enumeration
  350. enum **AreaParameter**:
  351. .. _class_PhysicsServer2D_constant_AREA_PARAM_GRAVITY_OVERRIDE_MODE:
  352. .. rst-class:: classref-enumeration-constant
  353. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_GRAVITY_OVERRIDE_MODE** = ``0``
  354. Constant to set/get gravity override mode in an area. See :ref:`AreaSpaceOverrideMode<enum_PhysicsServer2D_AreaSpaceOverrideMode>` for possible values. The default value of this parameter is :ref:`AREA_SPACE_OVERRIDE_DISABLED<class_PhysicsServer2D_constant_AREA_SPACE_OVERRIDE_DISABLED>`.
  355. .. _class_PhysicsServer2D_constant_AREA_PARAM_GRAVITY:
  356. .. rst-class:: classref-enumeration-constant
  357. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_GRAVITY** = ``1``
  358. Constant to set/get gravity strength in an area. The default value of this parameter is ``9.80665``.
  359. .. _class_PhysicsServer2D_constant_AREA_PARAM_GRAVITY_VECTOR:
  360. .. rst-class:: classref-enumeration-constant
  361. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_GRAVITY_VECTOR** = ``2``
  362. Constant to set/get gravity vector/center in an area. The default value of this parameter is ``Vector2(0, -1)``.
  363. .. _class_PhysicsServer2D_constant_AREA_PARAM_GRAVITY_IS_POINT:
  364. .. rst-class:: classref-enumeration-constant
  365. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_GRAVITY_IS_POINT** = ``3``
  366. Constant to set/get whether the gravity vector of an area is a direction, or a center point. The default value of this parameter is ``false``.
  367. .. _class_PhysicsServer2D_constant_AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE:
  368. .. rst-class:: classref-enumeration-constant
  369. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE** = ``4``
  370. Constant to set/get the distance at which the gravity strength is equal to the gravity controlled by :ref:`AREA_PARAM_GRAVITY<class_PhysicsServer2D_constant_AREA_PARAM_GRAVITY>`. For example, on a planet 100 pixels in radius with a surface gravity of 4.0 px/s², set the gravity to 4.0 and the unit distance to 100.0. The gravity will have falloff according to the inverse square law, so in the example, at 200 pixels from the center the gravity will be 1.0 px/s² (twice the distance, 1/4th the gravity), at 50 pixels it will be 16.0 px/s² (half the distance, 4x the gravity), and so on.
  371. The above is true only when the unit distance is a positive number. When the unit distance is set to 0.0, the gravity will be constant regardless of distance. The default value of this parameter is ``0.0``.
  372. .. _class_PhysicsServer2D_constant_AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE:
  373. .. rst-class:: classref-enumeration-constant
  374. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE** = ``5``
  375. Constant to set/get linear damping override mode in an area. See :ref:`AreaSpaceOverrideMode<enum_PhysicsServer2D_AreaSpaceOverrideMode>` for possible values. The default value of this parameter is :ref:`AREA_SPACE_OVERRIDE_DISABLED<class_PhysicsServer2D_constant_AREA_SPACE_OVERRIDE_DISABLED>`.
  376. .. _class_PhysicsServer2D_constant_AREA_PARAM_LINEAR_DAMP:
  377. .. rst-class:: classref-enumeration-constant
  378. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_LINEAR_DAMP** = ``6``
  379. Constant to set/get the linear damping factor of an area. The default value of this parameter is ``0.1``.
  380. .. _class_PhysicsServer2D_constant_AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE:
  381. .. rst-class:: classref-enumeration-constant
  382. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE** = ``7``
  383. Constant to set/get angular damping override mode in an area. See :ref:`AreaSpaceOverrideMode<enum_PhysicsServer2D_AreaSpaceOverrideMode>` for possible values. The default value of this parameter is :ref:`AREA_SPACE_OVERRIDE_DISABLED<class_PhysicsServer2D_constant_AREA_SPACE_OVERRIDE_DISABLED>`.
  384. .. _class_PhysicsServer2D_constant_AREA_PARAM_ANGULAR_DAMP:
  385. .. rst-class:: classref-enumeration-constant
  386. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_ANGULAR_DAMP** = ``8``
  387. Constant to set/get the angular damping factor of an area. The default value of this parameter is ``1.0``.
  388. .. _class_PhysicsServer2D_constant_AREA_PARAM_PRIORITY:
  389. .. rst-class:: classref-enumeration-constant
  390. :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` **AREA_PARAM_PRIORITY** = ``9``
  391. Constant to set/get the priority (order of processing) of an area. The default value of this parameter is ``0``.
  392. .. rst-class:: classref-item-separator
  393. ----
  394. .. _enum_PhysicsServer2D_AreaSpaceOverrideMode:
  395. .. rst-class:: classref-enumeration
  396. enum **AreaSpaceOverrideMode**:
  397. .. _class_PhysicsServer2D_constant_AREA_SPACE_OVERRIDE_DISABLED:
  398. .. rst-class:: classref-enumeration-constant
  399. :ref:`AreaSpaceOverrideMode<enum_PhysicsServer2D_AreaSpaceOverrideMode>` **AREA_SPACE_OVERRIDE_DISABLED** = ``0``
  400. This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
  401. .. _class_PhysicsServer2D_constant_AREA_SPACE_OVERRIDE_COMBINE:
  402. .. rst-class:: classref-enumeration-constant
  403. :ref:`AreaSpaceOverrideMode<enum_PhysicsServer2D_AreaSpaceOverrideMode>` **AREA_SPACE_OVERRIDE_COMBINE** = ``1``
  404. 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.
  405. .. _class_PhysicsServer2D_constant_AREA_SPACE_OVERRIDE_COMBINE_REPLACE:
  406. .. rst-class:: classref-enumeration-constant
  407. :ref:`AreaSpaceOverrideMode<enum_PhysicsServer2D_AreaSpaceOverrideMode>` **AREA_SPACE_OVERRIDE_COMBINE_REPLACE** = ``2``
  408. 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.
  409. .. _class_PhysicsServer2D_constant_AREA_SPACE_OVERRIDE_REPLACE:
  410. .. rst-class:: classref-enumeration-constant
  411. :ref:`AreaSpaceOverrideMode<enum_PhysicsServer2D_AreaSpaceOverrideMode>` **AREA_SPACE_OVERRIDE_REPLACE** = ``3``
  412. This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
  413. .. _class_PhysicsServer2D_constant_AREA_SPACE_OVERRIDE_REPLACE_COMBINE:
  414. .. rst-class:: classref-enumeration-constant
  415. :ref:`AreaSpaceOverrideMode<enum_PhysicsServer2D_AreaSpaceOverrideMode>` **AREA_SPACE_OVERRIDE_REPLACE_COMBINE** = ``4``
  416. This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
  417. .. rst-class:: classref-item-separator
  418. ----
  419. .. _enum_PhysicsServer2D_BodyMode:
  420. .. rst-class:: classref-enumeration
  421. enum **BodyMode**:
  422. .. _class_PhysicsServer2D_constant_BODY_MODE_STATIC:
  423. .. rst-class:: classref-enumeration-constant
  424. :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>` **BODY_MODE_STATIC** = ``0``
  425. 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.
  426. .. _class_PhysicsServer2D_constant_BODY_MODE_KINEMATIC:
  427. .. rst-class:: classref-enumeration-constant
  428. :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>` **BODY_MODE_KINEMATIC** = ``1``
  429. Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path.
  430. .. _class_PhysicsServer2D_constant_BODY_MODE_RIGID:
  431. .. rst-class:: classref-enumeration-constant
  432. :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>` **BODY_MODE_RIGID** = ``2``
  433. Constant for rigid bodies. In this mode, a body can be pushed by other bodies and has forces applied.
  434. .. _class_PhysicsServer2D_constant_BODY_MODE_RIGID_LINEAR:
  435. .. rst-class:: classref-enumeration-constant
  436. :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>` **BODY_MODE_RIGID_LINEAR** = ``3``
  437. Constant for linear rigid bodies. In this mode, a body can not rotate, and only its linear velocity is affected by external forces.
  438. .. rst-class:: classref-item-separator
  439. ----
  440. .. _enum_PhysicsServer2D_BodyParameter:
  441. .. rst-class:: classref-enumeration
  442. enum **BodyParameter**:
  443. .. _class_PhysicsServer2D_constant_BODY_PARAM_BOUNCE:
  444. .. rst-class:: classref-enumeration-constant
  445. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_BOUNCE** = ``0``
  446. Constant to set/get a body's bounce factor. The default value of this parameter is ``0.0``.
  447. .. _class_PhysicsServer2D_constant_BODY_PARAM_FRICTION:
  448. .. rst-class:: classref-enumeration-constant
  449. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_FRICTION** = ``1``
  450. Constant to set/get a body's friction. The default value of this parameter is ``1.0``.
  451. .. _class_PhysicsServer2D_constant_BODY_PARAM_MASS:
  452. .. rst-class:: classref-enumeration-constant
  453. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_MASS** = ``2``
  454. Constant to set/get a body's mass. The default value of this parameter is ``1.0``. If the body's mode is set to :ref:`BODY_MODE_RIGID<class_PhysicsServer2D_constant_BODY_MODE_RIGID>`, then setting this parameter will have the following additional effects:
  455. - If the parameter :ref:`BODY_PARAM_CENTER_OF_MASS<class_PhysicsServer2D_constant_BODY_PARAM_CENTER_OF_MASS>` has never been set explicitly, then the value of that parameter will be recalculated based on the body's shapes.
  456. - If the parameter :ref:`BODY_PARAM_INERTIA<class_PhysicsServer2D_constant_BODY_PARAM_INERTIA>` is set to a value ``<= 0.0``, then the value of that parameter will be recalculated based on the body's shapes, mass, and center of mass.
  457. .. _class_PhysicsServer2D_constant_BODY_PARAM_INERTIA:
  458. .. rst-class:: classref-enumeration-constant
  459. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_INERTIA** = ``3``
  460. Constant to set/get a body's inertia. The default value of this parameter is ``0.0``. If the body's inertia is set to a value ``<= 0.0``, then the inertia will be recalculated based on the body's shapes, mass, and center of mass.
  461. .. _class_PhysicsServer2D_constant_BODY_PARAM_CENTER_OF_MASS:
  462. .. rst-class:: classref-enumeration-constant
  463. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_CENTER_OF_MASS** = ``4``
  464. Constant to set/get a body's center of mass position in the body's local coordinate system. The default value of this parameter is ``Vector2(0,0)``. If this parameter is never set explicitly, then it is recalculated based on the body's shapes when setting the parameter :ref:`BODY_PARAM_MASS<class_PhysicsServer2D_constant_BODY_PARAM_MASS>` or when calling :ref:`body_set_space<class_PhysicsServer2D_method_body_set_space>`.
  465. .. _class_PhysicsServer2D_constant_BODY_PARAM_GRAVITY_SCALE:
  466. .. rst-class:: classref-enumeration-constant
  467. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_GRAVITY_SCALE** = ``5``
  468. Constant to set/get a body's gravity multiplier. The default value of this parameter is ``1.0``.
  469. .. _class_PhysicsServer2D_constant_BODY_PARAM_LINEAR_DAMP_MODE:
  470. .. rst-class:: classref-enumeration-constant
  471. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_LINEAR_DAMP_MODE** = ``6``
  472. Constant to set/get a body's linear damping mode. See :ref:`BodyDampMode<enum_PhysicsServer2D_BodyDampMode>` for possible values. The default value of this parameter is :ref:`BODY_DAMP_MODE_COMBINE<class_PhysicsServer2D_constant_BODY_DAMP_MODE_COMBINE>`.
  473. .. _class_PhysicsServer2D_constant_BODY_PARAM_ANGULAR_DAMP_MODE:
  474. .. rst-class:: classref-enumeration-constant
  475. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_ANGULAR_DAMP_MODE** = ``7``
  476. Constant to set/get a body's angular damping mode. See :ref:`BodyDampMode<enum_PhysicsServer2D_BodyDampMode>` for possible values. The default value of this parameter is :ref:`BODY_DAMP_MODE_COMBINE<class_PhysicsServer2D_constant_BODY_DAMP_MODE_COMBINE>`.
  477. .. _class_PhysicsServer2D_constant_BODY_PARAM_LINEAR_DAMP:
  478. .. rst-class:: classref-enumeration-constant
  479. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_LINEAR_DAMP** = ``8``
  480. Constant to set/get a body's linear damping factor. The default value of this parameter is ``0.0``.
  481. .. _class_PhysicsServer2D_constant_BODY_PARAM_ANGULAR_DAMP:
  482. .. rst-class:: classref-enumeration-constant
  483. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_ANGULAR_DAMP** = ``9``
  484. Constant to set/get a body's angular damping factor. The default value of this parameter is ``0.0``.
  485. .. _class_PhysicsServer2D_constant_BODY_PARAM_MAX:
  486. .. rst-class:: classref-enumeration-constant
  487. :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` **BODY_PARAM_MAX** = ``10``
  488. Represents the size of the :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` enum.
  489. .. rst-class:: classref-item-separator
  490. ----
  491. .. _enum_PhysicsServer2D_BodyDampMode:
  492. .. rst-class:: classref-enumeration
  493. enum **BodyDampMode**:
  494. .. _class_PhysicsServer2D_constant_BODY_DAMP_MODE_COMBINE:
  495. .. rst-class:: classref-enumeration-constant
  496. :ref:`BodyDampMode<enum_PhysicsServer2D_BodyDampMode>` **BODY_DAMP_MODE_COMBINE** = ``0``
  497. The body's damping value is added to any value set in areas or the default value.
  498. .. _class_PhysicsServer2D_constant_BODY_DAMP_MODE_REPLACE:
  499. .. rst-class:: classref-enumeration-constant
  500. :ref:`BodyDampMode<enum_PhysicsServer2D_BodyDampMode>` **BODY_DAMP_MODE_REPLACE** = ``1``
  501. The body's damping value replaces any value set in areas or the default value.
  502. .. rst-class:: classref-item-separator
  503. ----
  504. .. _enum_PhysicsServer2D_BodyState:
  505. .. rst-class:: classref-enumeration
  506. enum **BodyState**:
  507. .. _class_PhysicsServer2D_constant_BODY_STATE_TRANSFORM:
  508. .. rst-class:: classref-enumeration-constant
  509. :ref:`BodyState<enum_PhysicsServer2D_BodyState>` **BODY_STATE_TRANSFORM** = ``0``
  510. Constant to set/get the current transform matrix of the body.
  511. .. _class_PhysicsServer2D_constant_BODY_STATE_LINEAR_VELOCITY:
  512. .. rst-class:: classref-enumeration-constant
  513. :ref:`BodyState<enum_PhysicsServer2D_BodyState>` **BODY_STATE_LINEAR_VELOCITY** = ``1``
  514. Constant to set/get the current linear velocity of the body.
  515. .. _class_PhysicsServer2D_constant_BODY_STATE_ANGULAR_VELOCITY:
  516. .. rst-class:: classref-enumeration-constant
  517. :ref:`BodyState<enum_PhysicsServer2D_BodyState>` **BODY_STATE_ANGULAR_VELOCITY** = ``2``
  518. Constant to set/get the current angular velocity of the body.
  519. .. _class_PhysicsServer2D_constant_BODY_STATE_SLEEPING:
  520. .. rst-class:: classref-enumeration-constant
  521. :ref:`BodyState<enum_PhysicsServer2D_BodyState>` **BODY_STATE_SLEEPING** = ``3``
  522. Constant to sleep/wake up a body, or to get whether it is sleeping.
  523. .. _class_PhysicsServer2D_constant_BODY_STATE_CAN_SLEEP:
  524. .. rst-class:: classref-enumeration-constant
  525. :ref:`BodyState<enum_PhysicsServer2D_BodyState>` **BODY_STATE_CAN_SLEEP** = ``4``
  526. Constant to set/get whether the body can sleep.
  527. .. rst-class:: classref-item-separator
  528. ----
  529. .. _enum_PhysicsServer2D_JointType:
  530. .. rst-class:: classref-enumeration
  531. enum **JointType**:
  532. .. _class_PhysicsServer2D_constant_JOINT_TYPE_PIN:
  533. .. rst-class:: classref-enumeration-constant
  534. :ref:`JointType<enum_PhysicsServer2D_JointType>` **JOINT_TYPE_PIN** = ``0``
  535. Constant to create pin joints.
  536. .. _class_PhysicsServer2D_constant_JOINT_TYPE_GROOVE:
  537. .. rst-class:: classref-enumeration-constant
  538. :ref:`JointType<enum_PhysicsServer2D_JointType>` **JOINT_TYPE_GROOVE** = ``1``
  539. Constant to create groove joints.
  540. .. _class_PhysicsServer2D_constant_JOINT_TYPE_DAMPED_SPRING:
  541. .. rst-class:: classref-enumeration-constant
  542. :ref:`JointType<enum_PhysicsServer2D_JointType>` **JOINT_TYPE_DAMPED_SPRING** = ``2``
  543. Constant to create damped spring joints.
  544. .. _class_PhysicsServer2D_constant_JOINT_TYPE_MAX:
  545. .. rst-class:: classref-enumeration-constant
  546. :ref:`JointType<enum_PhysicsServer2D_JointType>` **JOINT_TYPE_MAX** = ``3``
  547. Represents the size of the :ref:`JointType<enum_PhysicsServer2D_JointType>` enum.
  548. .. rst-class:: classref-item-separator
  549. ----
  550. .. _enum_PhysicsServer2D_JointParam:
  551. .. rst-class:: classref-enumeration
  552. enum **JointParam**:
  553. .. _class_PhysicsServer2D_constant_JOINT_PARAM_BIAS:
  554. .. rst-class:: classref-enumeration-constant
  555. :ref:`JointParam<enum_PhysicsServer2D_JointParam>` **JOINT_PARAM_BIAS** = ``0``
  556. Constant to set/get how fast the joint pulls the bodies back to satisfy the joint constraint. The lower the value, the more the two bodies can pull on the joint. The default value of this parameter is ``0.0``.
  557. \ **Note:** In Godot Physics, this parameter is only used for pin joints and groove joints.
  558. .. _class_PhysicsServer2D_constant_JOINT_PARAM_MAX_BIAS:
  559. .. rst-class:: classref-enumeration-constant
  560. :ref:`JointParam<enum_PhysicsServer2D_JointParam>` **JOINT_PARAM_MAX_BIAS** = ``1``
  561. Constant to set/get the maximum speed with which the joint can apply corrections. The default value of this parameter is ``3.40282e+38``.
  562. \ **Note:** In Godot Physics, this parameter is only used for groove joints.
  563. .. _class_PhysicsServer2D_constant_JOINT_PARAM_MAX_FORCE:
  564. .. rst-class:: classref-enumeration-constant
  565. :ref:`JointParam<enum_PhysicsServer2D_JointParam>` **JOINT_PARAM_MAX_FORCE** = ``2``
  566. Constant to set/get the maximum force that the joint can use to act on the two bodies. The default value of this parameter is ``3.40282e+38``.
  567. \ **Note:** In Godot Physics, this parameter is only used for groove joints.
  568. .. rst-class:: classref-item-separator
  569. ----
  570. .. _enum_PhysicsServer2D_PinJointParam:
  571. .. rst-class:: classref-enumeration
  572. enum **PinJointParam**:
  573. .. _class_PhysicsServer2D_constant_PIN_JOINT_SOFTNESS:
  574. .. rst-class:: classref-enumeration-constant
  575. :ref:`PinJointParam<enum_PhysicsServer2D_PinJointParam>` **PIN_JOINT_SOFTNESS** = ``0``
  576. Constant to set/get a how much the bond of the pin joint can flex. The default value of this parameter is ``0.0``.
  577. .. rst-class:: classref-item-separator
  578. ----
  579. .. _enum_PhysicsServer2D_DampedSpringParam:
  580. .. rst-class:: classref-enumeration
  581. enum **DampedSpringParam**:
  582. .. _class_PhysicsServer2D_constant_DAMPED_SPRING_REST_LENGTH:
  583. .. rst-class:: classref-enumeration-constant
  584. :ref:`DampedSpringParam<enum_PhysicsServer2D_DampedSpringParam>` **DAMPED_SPRING_REST_LENGTH** = ``0``
  585. Sets the resting length of the spring joint. The joint will always try to go to back this length when pulled apart. The default value of this parameter is the distance between the joint's anchor points.
  586. .. _class_PhysicsServer2D_constant_DAMPED_SPRING_STIFFNESS:
  587. .. rst-class:: classref-enumeration-constant
  588. :ref:`DampedSpringParam<enum_PhysicsServer2D_DampedSpringParam>` **DAMPED_SPRING_STIFFNESS** = ``1``
  589. Sets the stiffness of the spring joint. The joint applies a force equal to the stiffness times the distance from its resting length. The default value of this parameter is ``20.0``.
  590. .. _class_PhysicsServer2D_constant_DAMPED_SPRING_DAMPING:
  591. .. rst-class:: classref-enumeration-constant
  592. :ref:`DampedSpringParam<enum_PhysicsServer2D_DampedSpringParam>` **DAMPED_SPRING_DAMPING** = ``2``
  593. 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). The default value of this parameter is ``1.5``.
  594. .. rst-class:: classref-item-separator
  595. ----
  596. .. _enum_PhysicsServer2D_CCDMode:
  597. .. rst-class:: classref-enumeration
  598. enum **CCDMode**:
  599. .. _class_PhysicsServer2D_constant_CCD_MODE_DISABLED:
  600. .. rst-class:: classref-enumeration-constant
  601. :ref:`CCDMode<enum_PhysicsServer2D_CCDMode>` **CCD_MODE_DISABLED** = ``0``
  602. Disables continuous collision detection. This is the fastest way to detect body collisions, but it can miss small and/or fast-moving objects.
  603. .. _class_PhysicsServer2D_constant_CCD_MODE_CAST_RAY:
  604. .. rst-class:: classref-enumeration-constant
  605. :ref:`CCDMode<enum_PhysicsServer2D_CCDMode>` **CCD_MODE_CAST_RAY** = ``1``
  606. Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise.
  607. .. _class_PhysicsServer2D_constant_CCD_MODE_CAST_SHAPE:
  608. .. rst-class:: classref-enumeration-constant
  609. :ref:`CCDMode<enum_PhysicsServer2D_CCDMode>` **CCD_MODE_CAST_SHAPE** = ``2``
  610. Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise.
  611. .. rst-class:: classref-item-separator
  612. ----
  613. .. _enum_PhysicsServer2D_AreaBodyStatus:
  614. .. rst-class:: classref-enumeration
  615. enum **AreaBodyStatus**:
  616. .. _class_PhysicsServer2D_constant_AREA_BODY_ADDED:
  617. .. rst-class:: classref-enumeration-constant
  618. :ref:`AreaBodyStatus<enum_PhysicsServer2D_AreaBodyStatus>` **AREA_BODY_ADDED** = ``0``
  619. The value of the first parameter and area callback function receives, when an object enters one of its shapes.
  620. .. _class_PhysicsServer2D_constant_AREA_BODY_REMOVED:
  621. .. rst-class:: classref-enumeration-constant
  622. :ref:`AreaBodyStatus<enum_PhysicsServer2D_AreaBodyStatus>` **AREA_BODY_REMOVED** = ``1``
  623. The value of the first parameter and area callback function receives, when an object exits one of its shapes.
  624. .. rst-class:: classref-item-separator
  625. ----
  626. .. _enum_PhysicsServer2D_ProcessInfo:
  627. .. rst-class:: classref-enumeration
  628. enum **ProcessInfo**:
  629. .. _class_PhysicsServer2D_constant_INFO_ACTIVE_OBJECTS:
  630. .. rst-class:: classref-enumeration-constant
  631. :ref:`ProcessInfo<enum_PhysicsServer2D_ProcessInfo>` **INFO_ACTIVE_OBJECTS** = ``0``
  632. Constant to get the number of objects that are not sleeping.
  633. .. _class_PhysicsServer2D_constant_INFO_COLLISION_PAIRS:
  634. .. rst-class:: classref-enumeration-constant
  635. :ref:`ProcessInfo<enum_PhysicsServer2D_ProcessInfo>` **INFO_COLLISION_PAIRS** = ``1``
  636. Constant to get the number of possible collisions.
  637. .. _class_PhysicsServer2D_constant_INFO_ISLAND_COUNT:
  638. .. rst-class:: classref-enumeration-constant
  639. :ref:`ProcessInfo<enum_PhysicsServer2D_ProcessInfo>` **INFO_ISLAND_COUNT** = ``2``
  640. Constant to get the number of space regions where a collision could occur.
  641. .. rst-class:: classref-section-separator
  642. ----
  643. .. rst-class:: classref-descriptions-group
  644. Method Descriptions
  645. -------------------
  646. .. _class_PhysicsServer2D_method_area_add_shape:
  647. .. rst-class:: classref-method
  648. void **area_add_shape** **(** :ref:`RID<class_RID>` area, :ref:`RID<class_RID>` shape, :ref:`Transform2D<class_Transform2D>` transform=Transform2D(1, 0, 0, 1, 0, 0), :ref:`bool<class_bool>` disabled=false **)**
  649. Adds a shape to the area, with the given local transform. The shape (together with its ``transform`` and ``disabled`` properties) is added to an array of shapes, and the shapes of an area are usually referenced by their index in this array.
  650. .. rst-class:: classref-item-separator
  651. ----
  652. .. _class_PhysicsServer2D_method_area_attach_canvas_instance_id:
  653. .. rst-class:: classref-method
  654. void **area_attach_canvas_instance_id** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` id **)**
  655. Attaches the ``ObjectID`` of a canvas to the area. Use :ref:`Object.get_instance_id<class_Object_method_get_instance_id>` to get the ``ObjectID`` of a :ref:`CanvasLayer<class_CanvasLayer>`.
  656. .. rst-class:: classref-item-separator
  657. ----
  658. .. _class_PhysicsServer2D_method_area_attach_object_instance_id:
  659. .. rst-class:: classref-method
  660. void **area_attach_object_instance_id** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` id **)**
  661. Attaches the ``ObjectID`` of an :ref:`Object<class_Object>` to the area. Use :ref:`Object.get_instance_id<class_Object_method_get_instance_id>` to get the ``ObjectID`` of a :ref:`CollisionObject2D<class_CollisionObject2D>`.
  662. .. rst-class:: classref-item-separator
  663. ----
  664. .. _class_PhysicsServer2D_method_area_clear_shapes:
  665. .. rst-class:: classref-method
  666. void **area_clear_shapes** **(** :ref:`RID<class_RID>` area **)**
  667. Removes all shapes from the area. This does not delete the shapes themselves, so they can continue to be used elsewhere or added back later.
  668. .. rst-class:: classref-item-separator
  669. ----
  670. .. _class_PhysicsServer2D_method_area_create:
  671. .. rst-class:: classref-method
  672. :ref:`RID<class_RID>` **area_create** **(** **)**
  673. Creates a 2D area object in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`area_add_shape<class_PhysicsServer2D_method_area_add_shape>` to add shapes to it, use :ref:`area_set_transform<class_PhysicsServer2D_method_area_set_transform>` to set its transform, and use :ref:`area_set_space<class_PhysicsServer2D_method_area_set_space>` to add the area to a space.
  674. .. rst-class:: classref-item-separator
  675. ----
  676. .. _class_PhysicsServer2D_method_area_get_canvas_instance_id:
  677. .. rst-class:: classref-method
  678. :ref:`int<class_int>` **area_get_canvas_instance_id** **(** :ref:`RID<class_RID>` area **)** |const|
  679. Returns the ``ObjectID`` of the canvas attached to the area. Use :ref:`@GlobalScope.instance_from_id<class_@GlobalScope_method_instance_from_id>` to retrieve a :ref:`CanvasLayer<class_CanvasLayer>` from a nonzero ``ObjectID``.
  680. .. rst-class:: classref-item-separator
  681. ----
  682. .. _class_PhysicsServer2D_method_area_get_collision_layer:
  683. .. rst-class:: classref-method
  684. :ref:`int<class_int>` **area_get_collision_layer** **(** :ref:`RID<class_RID>` area **)** |const|
  685. Returns the physics layer or layers the area belongs to, as a bitmask.
  686. .. rst-class:: classref-item-separator
  687. ----
  688. .. _class_PhysicsServer2D_method_area_get_collision_mask:
  689. .. rst-class:: classref-method
  690. :ref:`int<class_int>` **area_get_collision_mask** **(** :ref:`RID<class_RID>` area **)** |const|
  691. Returns the physics layer or layers the area can contact with, as a bitmask.
  692. .. rst-class:: classref-item-separator
  693. ----
  694. .. _class_PhysicsServer2D_method_area_get_object_instance_id:
  695. .. rst-class:: classref-method
  696. :ref:`int<class_int>` **area_get_object_instance_id** **(** :ref:`RID<class_RID>` area **)** |const|
  697. Returns the ``ObjectID`` attached to the area. Use :ref:`@GlobalScope.instance_from_id<class_@GlobalScope_method_instance_from_id>` to retrieve an :ref:`Object<class_Object>` from a nonzero ``ObjectID``.
  698. .. rst-class:: classref-item-separator
  699. ----
  700. .. _class_PhysicsServer2D_method_area_get_param:
  701. .. rst-class:: classref-method
  702. :ref:`Variant<class_Variant>` **area_get_param** **(** :ref:`RID<class_RID>` area, :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` param **)** |const|
  703. Returns the value of the given area parameter. See :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` for the list of available parameters.
  704. .. rst-class:: classref-item-separator
  705. ----
  706. .. _class_PhysicsServer2D_method_area_get_shape:
  707. .. rst-class:: classref-method
  708. :ref:`RID<class_RID>` **area_get_shape** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx **)** |const|
  709. Returns the :ref:`RID<class_RID>` of the shape with the given index in the area's array of shapes.
  710. .. rst-class:: classref-item-separator
  711. ----
  712. .. _class_PhysicsServer2D_method_area_get_shape_count:
  713. .. rst-class:: classref-method
  714. :ref:`int<class_int>` **area_get_shape_count** **(** :ref:`RID<class_RID>` area **)** |const|
  715. Returns the number of shapes added to the area.
  716. .. rst-class:: classref-item-separator
  717. ----
  718. .. _class_PhysicsServer2D_method_area_get_shape_transform:
  719. .. rst-class:: classref-method
  720. :ref:`Transform2D<class_Transform2D>` **area_get_shape_transform** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx **)** |const|
  721. Returns the local transform matrix of the shape with the given index in the area's array of shapes.
  722. .. rst-class:: classref-item-separator
  723. ----
  724. .. _class_PhysicsServer2D_method_area_get_space:
  725. .. rst-class:: classref-method
  726. :ref:`RID<class_RID>` **area_get_space** **(** :ref:`RID<class_RID>` area **)** |const|
  727. Returns the :ref:`RID<class_RID>` of the space assigned to the area. Returns ``RID()`` if no space is assigned.
  728. .. rst-class:: classref-item-separator
  729. ----
  730. .. _class_PhysicsServer2D_method_area_get_transform:
  731. .. rst-class:: classref-method
  732. :ref:`Transform2D<class_Transform2D>` **area_get_transform** **(** :ref:`RID<class_RID>` area **)** |const|
  733. Returns the transform matrix of the area.
  734. .. rst-class:: classref-item-separator
  735. ----
  736. .. _class_PhysicsServer2D_method_area_remove_shape:
  737. .. rst-class:: classref-method
  738. void **area_remove_shape** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx **)**
  739. Removes the shape with the given index from the area's array of shapes. The shape itself is not deleted, so it can continue to be used elsewhere or added back later. As a result of this operation, the area's shapes which used to have indices higher than ``shape_idx`` will have their index decreased by one.
  740. .. rst-class:: classref-item-separator
  741. ----
  742. .. _class_PhysicsServer2D_method_area_set_area_monitor_callback:
  743. .. rst-class:: classref-method
  744. void **area_set_area_monitor_callback** **(** :ref:`RID<class_RID>` area, :ref:`Callable<class_Callable>` callback **)**
  745. Sets the area's area monitor callback. This callback will be called when any other (shape of an) area enters or exits (a shape of) the given area, and must take the following five parameters:
  746. 1. an integer ``status``: either :ref:`AREA_BODY_ADDED<class_PhysicsServer2D_constant_AREA_BODY_ADDED>` or :ref:`AREA_BODY_REMOVED<class_PhysicsServer2D_constant_AREA_BODY_REMOVED>` depending on whether the other area's shape entered or exited the area,
  747. 2. an :ref:`RID<class_RID>` ``area_rid``: the :ref:`RID<class_RID>` of the other area that entered or exited the area,
  748. 3. an integer ``instance_id``: the ``ObjectID`` attached to the other area,
  749. 4. an integer ``area_shape_idx``: the index of the shape of the other area that entered or exited the area,
  750. 5. an integer ``self_shape_idx``: the index of the shape of the area where the other area entered or exited.
  751. By counting (or keeping track of) the shapes that enter and exit, it can be determined if an area (with all its shapes) is entering for the first time or exiting for the last time.
  752. .. rst-class:: classref-item-separator
  753. ----
  754. .. _class_PhysicsServer2D_method_area_set_collision_layer:
  755. .. rst-class:: classref-method
  756. void **area_set_collision_layer** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` layer **)**
  757. Assigns the area to one or many physics layers, via a bitmask.
  758. .. rst-class:: classref-item-separator
  759. ----
  760. .. _class_PhysicsServer2D_method_area_set_collision_mask:
  761. .. rst-class:: classref-method
  762. void **area_set_collision_mask** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` mask **)**
  763. Sets which physics layers the area will monitor, via a bitmask.
  764. .. rst-class:: classref-item-separator
  765. ----
  766. .. _class_PhysicsServer2D_method_area_set_monitor_callback:
  767. .. rst-class:: classref-method
  768. void **area_set_monitor_callback** **(** :ref:`RID<class_RID>` area, :ref:`Callable<class_Callable>` callback **)**
  769. Sets the area's body monitor callback. This callback will be called when any other (shape of a) body enters or exits (a shape of) the given area, and must take the following five parameters:
  770. 1. an integer ``status``: either :ref:`AREA_BODY_ADDED<class_PhysicsServer2D_constant_AREA_BODY_ADDED>` or :ref:`AREA_BODY_REMOVED<class_PhysicsServer2D_constant_AREA_BODY_REMOVED>` depending on whether the other body shape entered or exited the area,
  771. 2. an :ref:`RID<class_RID>` ``body_rid``: the :ref:`RID<class_RID>` of the body that entered or exited the area,
  772. 3. an integer ``instance_id``: the ``ObjectID`` attached to the body,
  773. 4. an integer ``body_shape_idx``: the index of the shape of the body that entered or exited the area,
  774. 5. an integer ``self_shape_idx``: the index of the shape of the area where the body entered or exited.
  775. By counting (or keeping track of) the shapes that enter and exit, it can be determined if a body (with all its shapes) is entering for the first time or exiting for the last time.
  776. .. rst-class:: classref-item-separator
  777. ----
  778. .. _class_PhysicsServer2D_method_area_set_monitorable:
  779. .. rst-class:: classref-method
  780. void **area_set_monitorable** **(** :ref:`RID<class_RID>` area, :ref:`bool<class_bool>` monitorable **)**
  781. Sets whether the area is monitorable or not. If ``monitorable`` is ``true``, the area monitoring callback of other areas will be called when this area enters or exits them.
  782. .. rst-class:: classref-item-separator
  783. ----
  784. .. _class_PhysicsServer2D_method_area_set_param:
  785. .. rst-class:: classref-method
  786. void **area_set_param** **(** :ref:`RID<class_RID>` area, :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` param, :ref:`Variant<class_Variant>` value **)**
  787. Sets the value of the given area parameter. See :ref:`AreaParameter<enum_PhysicsServer2D_AreaParameter>` for the list of available parameters.
  788. .. rst-class:: classref-item-separator
  789. ----
  790. .. _class_PhysicsServer2D_method_area_set_shape:
  791. .. rst-class:: classref-method
  792. void **area_set_shape** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx, :ref:`RID<class_RID>` shape **)**
  793. Replaces the area's shape at the given index by another shape, while not affecting the ``transform`` and ``disabled`` properties at the same index.
  794. .. rst-class:: classref-item-separator
  795. ----
  796. .. _class_PhysicsServer2D_method_area_set_shape_disabled:
  797. .. rst-class:: classref-method
  798. void **area_set_shape_disabled** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` disabled **)**
  799. Sets the disabled property of the area's shape with the given index. If ``disabled`` is ``true``, then the shape will not detect any other shapes entering or exiting it.
  800. .. rst-class:: classref-item-separator
  801. ----
  802. .. _class_PhysicsServer2D_method_area_set_shape_transform:
  803. .. rst-class:: classref-method
  804. void **area_set_shape_transform** **(** :ref:`RID<class_RID>` area, :ref:`int<class_int>` shape_idx, :ref:`Transform2D<class_Transform2D>` transform **)**
  805. Sets the local transform matrix of the area's shape with the given index.
  806. .. rst-class:: classref-item-separator
  807. ----
  808. .. _class_PhysicsServer2D_method_area_set_space:
  809. .. rst-class:: classref-method
  810. void **area_set_space** **(** :ref:`RID<class_RID>` area, :ref:`RID<class_RID>` space **)**
  811. Adds the area to the given space, after removing the area from the previously assigned space (if any).
  812. \ **Note:** To remove an area from a space without immediately adding it back elsewhere, use ``PhysicsServer2D.area_set_space(area, RID())``.
  813. .. rst-class:: classref-item-separator
  814. ----
  815. .. _class_PhysicsServer2D_method_area_set_transform:
  816. .. rst-class:: classref-method
  817. void **area_set_transform** **(** :ref:`RID<class_RID>` area, :ref:`Transform2D<class_Transform2D>` transform **)**
  818. Sets the transform matrix of the area.
  819. .. rst-class:: classref-item-separator
  820. ----
  821. .. _class_PhysicsServer2D_method_body_add_collision_exception:
  822. .. rst-class:: classref-method
  823. void **body_add_collision_exception** **(** :ref:`RID<class_RID>` body, :ref:`RID<class_RID>` excepted_body **)**
  824. Adds ``excepted_body`` to the body's list of collision exceptions, so that collisions with it are ignored.
  825. .. rst-class:: classref-item-separator
  826. ----
  827. .. _class_PhysicsServer2D_method_body_add_constant_central_force:
  828. .. rst-class:: classref-method
  829. void **body_add_constant_central_force** **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force **)**
  830. Adds a constant directional force to the body. The force does not affect rotation. The force remains applied over time until cleared with ``PhysicsServer2D.body_set_constant_force(body, Vector2(0, 0))``.
  831. This is equivalent to using :ref:`body_add_constant_force<class_PhysicsServer2D_method_body_add_constant_force>` at the body's center of mass.
  832. .. rst-class:: classref-item-separator
  833. ----
  834. .. _class_PhysicsServer2D_method_body_add_constant_force:
  835. .. rst-class:: classref-method
  836. void **body_add_constant_force** **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force, :ref:`Vector2<class_Vector2>` position=Vector2(0, 0) **)**
  837. Adds a constant positioned force to the body. The force can affect rotation if ``position`` is different from the body's center of mass. The force remains applied over time until cleared with ``PhysicsServer2D.body_set_constant_force(body, Vector2(0, 0))``.
  838. \ ``position`` is the offset from the body origin in global coordinates.
  839. .. rst-class:: classref-item-separator
  840. ----
  841. .. _class_PhysicsServer2D_method_body_add_constant_torque:
  842. .. rst-class:: classref-method
  843. void **body_add_constant_torque** **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` torque **)**
  844. Adds a constant rotational force to the body. The force does not affect position. The force remains applied over time until cleared with ``PhysicsServer2D.body_set_constant_torque(body, 0)``.
  845. .. rst-class:: classref-item-separator
  846. ----
  847. .. _class_PhysicsServer2D_method_body_add_shape:
  848. .. rst-class:: classref-method
  849. void **body_add_shape** **(** :ref:`RID<class_RID>` body, :ref:`RID<class_RID>` shape, :ref:`Transform2D<class_Transform2D>` transform=Transform2D(1, 0, 0, 1, 0, 0), :ref:`bool<class_bool>` disabled=false **)**
  850. Adds a shape to the area, with the given local transform. The shape (together with its ``transform`` and ``disabled`` properties) is added to an array of shapes, and the shapes of a body are usually referenced by their index in this array.
  851. .. rst-class:: classref-item-separator
  852. ----
  853. .. _class_PhysicsServer2D_method_body_apply_central_force:
  854. .. rst-class:: classref-method
  855. void **body_apply_central_force** **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force **)**
  856. Applies a directional force to the body, at the body's center of mass. The force does not affect rotation. A force is time dependent and meant to be applied every physics update.
  857. This is equivalent to using :ref:`body_apply_force<class_PhysicsServer2D_method_body_apply_force>` at the body's center of mass.
  858. .. rst-class:: classref-item-separator
  859. ----
  860. .. _class_PhysicsServer2D_method_body_apply_central_impulse:
  861. .. rst-class:: classref-method
  862. void **body_apply_central_impulse** **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` impulse **)**
  863. Applies a directional impulse to the body, at the body's center of mass. The impulse does not affect rotation.
  864. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
  865. This is equivalent to using :ref:`body_apply_impulse<class_PhysicsServer2D_method_body_apply_impulse>` at the body's center of mass.
  866. .. rst-class:: classref-item-separator
  867. ----
  868. .. _class_PhysicsServer2D_method_body_apply_force:
  869. .. rst-class:: classref-method
  870. void **body_apply_force** **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force, :ref:`Vector2<class_Vector2>` position=Vector2(0, 0) **)**
  871. Applies a positioned force to the body. The force can affect rotation if ``position`` is different from the body's center of mass. A force is time dependent and meant to be applied every physics update.
  872. \ ``position`` is the offset from the body origin in global coordinates.
  873. .. rst-class:: classref-item-separator
  874. ----
  875. .. _class_PhysicsServer2D_method_body_apply_impulse:
  876. .. rst-class:: classref-method
  877. void **body_apply_impulse** **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` impulse, :ref:`Vector2<class_Vector2>` position=Vector2(0, 0) **)**
  878. Applies a positioned impulse to the body. The impulse can affect rotation if ``position`` is different from the body's center of mass.
  879. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
  880. \ ``position`` is the offset from the body origin in global coordinates.
  881. .. rst-class:: classref-item-separator
  882. ----
  883. .. _class_PhysicsServer2D_method_body_apply_torque:
  884. .. rst-class:: classref-method
  885. void **body_apply_torque** **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` torque **)**
  886. Applies a rotational force to the body. The force does not affect position. A force is time dependent and meant to be applied every physics update.
  887. .. rst-class:: classref-item-separator
  888. ----
  889. .. _class_PhysicsServer2D_method_body_apply_torque_impulse:
  890. .. rst-class:: classref-method
  891. void **body_apply_torque_impulse** **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` impulse **)**
  892. Applies a rotational impulse to the body. The impulse does not affect position.
  893. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise).
  894. .. rst-class:: classref-item-separator
  895. ----
  896. .. _class_PhysicsServer2D_method_body_attach_canvas_instance_id:
  897. .. rst-class:: classref-method
  898. void **body_attach_canvas_instance_id** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` id **)**
  899. Attaches the ``ObjectID`` of a canvas to the body. Use :ref:`Object.get_instance_id<class_Object_method_get_instance_id>` to get the ``ObjectID`` of a :ref:`CanvasLayer<class_CanvasLayer>`.
  900. .. rst-class:: classref-item-separator
  901. ----
  902. .. _class_PhysicsServer2D_method_body_attach_object_instance_id:
  903. .. rst-class:: classref-method
  904. void **body_attach_object_instance_id** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` id **)**
  905. Attaches the ``ObjectID`` of an :ref:`Object<class_Object>` to the body. Use :ref:`Object.get_instance_id<class_Object_method_get_instance_id>` to get the ``ObjectID`` of a :ref:`CollisionObject2D<class_CollisionObject2D>`.
  906. .. rst-class:: classref-item-separator
  907. ----
  908. .. _class_PhysicsServer2D_method_body_clear_shapes:
  909. .. rst-class:: classref-method
  910. void **body_clear_shapes** **(** :ref:`RID<class_RID>` body **)**
  911. Removes all shapes from the body. This does not delete the shapes themselves, so they can continue to be used elsewhere or added back later.
  912. .. rst-class:: classref-item-separator
  913. ----
  914. .. _class_PhysicsServer2D_method_body_create:
  915. .. rst-class:: classref-method
  916. :ref:`RID<class_RID>` **body_create** **(** **)**
  917. Creates a 2D body object in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`body_add_shape<class_PhysicsServer2D_method_body_add_shape>` to add shapes to it, use :ref:`body_set_state<class_PhysicsServer2D_method_body_set_state>` to set its transform, and use :ref:`body_set_space<class_PhysicsServer2D_method_body_set_space>` to add the body to a space.
  918. .. rst-class:: classref-item-separator
  919. ----
  920. .. _class_PhysicsServer2D_method_body_get_canvas_instance_id:
  921. .. rst-class:: classref-method
  922. :ref:`int<class_int>` **body_get_canvas_instance_id** **(** :ref:`RID<class_RID>` body **)** |const|
  923. Returns the ``ObjectID`` of the canvas attached to the body. Use :ref:`@GlobalScope.instance_from_id<class_@GlobalScope_method_instance_from_id>` to retrieve a :ref:`CanvasLayer<class_CanvasLayer>` from a nonzero ``ObjectID``.
  924. .. rst-class:: classref-item-separator
  925. ----
  926. .. _class_PhysicsServer2D_method_body_get_collision_layer:
  927. .. rst-class:: classref-method
  928. :ref:`int<class_int>` **body_get_collision_layer** **(** :ref:`RID<class_RID>` body **)** |const|
  929. Returns the physics layer or layers the body belongs to, as a bitmask.
  930. .. rst-class:: classref-item-separator
  931. ----
  932. .. _class_PhysicsServer2D_method_body_get_collision_mask:
  933. .. rst-class:: classref-method
  934. :ref:`int<class_int>` **body_get_collision_mask** **(** :ref:`RID<class_RID>` body **)** |const|
  935. Returns the physics layer or layers the body can collide with, as a bitmask.
  936. .. rst-class:: classref-item-separator
  937. ----
  938. .. _class_PhysicsServer2D_method_body_get_collision_priority:
  939. .. rst-class:: classref-method
  940. :ref:`float<class_float>` **body_get_collision_priority** **(** :ref:`RID<class_RID>` body **)** |const|
  941. Returns the body's collision priority. This is used in the depenetration phase of :ref:`body_test_motion<class_PhysicsServer2D_method_body_test_motion>`. The higher the priority is, the lower the penetration into the body will be.
  942. .. rst-class:: classref-item-separator
  943. ----
  944. .. _class_PhysicsServer2D_method_body_get_constant_force:
  945. .. rst-class:: classref-method
  946. :ref:`Vector2<class_Vector2>` **body_get_constant_force** **(** :ref:`RID<class_RID>` body **)** |const|
  947. Returns the body's total constant positional force applied during each physics update.
  948. See :ref:`body_add_constant_force<class_PhysicsServer2D_method_body_add_constant_force>` and :ref:`body_add_constant_central_force<class_PhysicsServer2D_method_body_add_constant_central_force>`.
  949. .. rst-class:: classref-item-separator
  950. ----
  951. .. _class_PhysicsServer2D_method_body_get_constant_torque:
  952. .. rst-class:: classref-method
  953. :ref:`float<class_float>` **body_get_constant_torque** **(** :ref:`RID<class_RID>` body **)** |const|
  954. Returns the body's total constant rotational force applied during each physics update.
  955. See :ref:`body_add_constant_torque<class_PhysicsServer2D_method_body_add_constant_torque>`.
  956. .. rst-class:: classref-item-separator
  957. ----
  958. .. _class_PhysicsServer2D_method_body_get_continuous_collision_detection_mode:
  959. .. rst-class:: classref-method
  960. :ref:`CCDMode<enum_PhysicsServer2D_CCDMode>` **body_get_continuous_collision_detection_mode** **(** :ref:`RID<class_RID>` body **)** |const|
  961. Returns the body's continuous collision detection mode (see :ref:`CCDMode<enum_PhysicsServer2D_CCDMode>`).
  962. .. rst-class:: classref-item-separator
  963. ----
  964. .. _class_PhysicsServer2D_method_body_get_direct_state:
  965. .. rst-class:: classref-method
  966. :ref:`PhysicsDirectBodyState2D<class_PhysicsDirectBodyState2D>` **body_get_direct_state** **(** :ref:`RID<class_RID>` body **)**
  967. Returns the :ref:`PhysicsDirectBodyState2D<class_PhysicsDirectBodyState2D>` of the body. Returns ``null`` if the body is destroyed or not assigned to a space.
  968. .. rst-class:: classref-item-separator
  969. ----
  970. .. _class_PhysicsServer2D_method_body_get_max_contacts_reported:
  971. .. rst-class:: classref-method
  972. :ref:`int<class_int>` **body_get_max_contacts_reported** **(** :ref:`RID<class_RID>` body **)** |const|
  973. Returns the maximum number of contacts that the body can report. See :ref:`body_set_max_contacts_reported<class_PhysicsServer2D_method_body_set_max_contacts_reported>`.
  974. .. rst-class:: classref-item-separator
  975. ----
  976. .. _class_PhysicsServer2D_method_body_get_mode:
  977. .. rst-class:: classref-method
  978. :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>` **body_get_mode** **(** :ref:`RID<class_RID>` body **)** |const|
  979. Returns the body's mode (see :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>`).
  980. .. rst-class:: classref-item-separator
  981. ----
  982. .. _class_PhysicsServer2D_method_body_get_object_instance_id:
  983. .. rst-class:: classref-method
  984. :ref:`int<class_int>` **body_get_object_instance_id** **(** :ref:`RID<class_RID>` body **)** |const|
  985. Returns the ``ObjectID`` attached to the body. Use :ref:`@GlobalScope.instance_from_id<class_@GlobalScope_method_instance_from_id>` to retrieve an :ref:`Object<class_Object>` from a nonzero ``ObjectID``.
  986. .. rst-class:: classref-item-separator
  987. ----
  988. .. _class_PhysicsServer2D_method_body_get_param:
  989. .. rst-class:: classref-method
  990. :ref:`Variant<class_Variant>` **body_get_param** **(** :ref:`RID<class_RID>` body, :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` param **)** |const|
  991. Returns the value of the given body parameter. See :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` for the list of available parameters.
  992. .. rst-class:: classref-item-separator
  993. ----
  994. .. _class_PhysicsServer2D_method_body_get_shape:
  995. .. rst-class:: classref-method
  996. :ref:`RID<class_RID>` **body_get_shape** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx **)** |const|
  997. Returns the :ref:`RID<class_RID>` of the shape with the given index in the body's array of shapes.
  998. .. rst-class:: classref-item-separator
  999. ----
  1000. .. _class_PhysicsServer2D_method_body_get_shape_count:
  1001. .. rst-class:: classref-method
  1002. :ref:`int<class_int>` **body_get_shape_count** **(** :ref:`RID<class_RID>` body **)** |const|
  1003. Returns the number of shapes added to the body.
  1004. .. rst-class:: classref-item-separator
  1005. ----
  1006. .. _class_PhysicsServer2D_method_body_get_shape_transform:
  1007. .. rst-class:: classref-method
  1008. :ref:`Transform2D<class_Transform2D>` **body_get_shape_transform** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx **)** |const|
  1009. Returns the local transform matrix of the shape with the given index in the area's array of shapes.
  1010. .. rst-class:: classref-item-separator
  1011. ----
  1012. .. _class_PhysicsServer2D_method_body_get_space:
  1013. .. rst-class:: classref-method
  1014. :ref:`RID<class_RID>` **body_get_space** **(** :ref:`RID<class_RID>` body **)** |const|
  1015. Returns the :ref:`RID<class_RID>` of the space assigned to the body. Returns ``RID()`` if no space is assigned.
  1016. .. rst-class:: classref-item-separator
  1017. ----
  1018. .. _class_PhysicsServer2D_method_body_get_state:
  1019. .. rst-class:: classref-method
  1020. :ref:`Variant<class_Variant>` **body_get_state** **(** :ref:`RID<class_RID>` body, :ref:`BodyState<enum_PhysicsServer2D_BodyState>` state **)** |const|
  1021. Returns the value of the given state of the body. See :ref:`BodyState<enum_PhysicsServer2D_BodyState>` for the list of available states.
  1022. .. rst-class:: classref-item-separator
  1023. ----
  1024. .. _class_PhysicsServer2D_method_body_is_omitting_force_integration:
  1025. .. rst-class:: classref-method
  1026. :ref:`bool<class_bool>` **body_is_omitting_force_integration** **(** :ref:`RID<class_RID>` body **)** |const|
  1027. Returns ``true`` if the body uses a callback function to calculate its own physics (see :ref:`body_set_force_integration_callback<class_PhysicsServer2D_method_body_set_force_integration_callback>`).
  1028. .. rst-class:: classref-item-separator
  1029. ----
  1030. .. _class_PhysicsServer2D_method_body_remove_collision_exception:
  1031. .. rst-class:: classref-method
  1032. void **body_remove_collision_exception** **(** :ref:`RID<class_RID>` body, :ref:`RID<class_RID>` excepted_body **)**
  1033. Removes ``excepted_body`` from the body's list of collision exceptions, so that collisions with it are no longer ignored.
  1034. .. rst-class:: classref-item-separator
  1035. ----
  1036. .. _class_PhysicsServer2D_method_body_remove_shape:
  1037. .. rst-class:: classref-method
  1038. void **body_remove_shape** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx **)**
  1039. Removes the shape with the given index from the body's array of shapes. The shape itself is not deleted, so it can continue to be used elsewhere or added back later. As a result of this operation, the body's shapes which used to have indices higher than ``shape_idx`` will have their index decreased by one.
  1040. .. rst-class:: classref-item-separator
  1041. ----
  1042. .. _class_PhysicsServer2D_method_body_reset_mass_properties:
  1043. .. rst-class:: classref-method
  1044. void **body_reset_mass_properties** **(** :ref:`RID<class_RID>` body **)**
  1045. Restores the default inertia and center of mass of the body based on its shapes. This undoes any custom values previously set using :ref:`body_set_param<class_PhysicsServer2D_method_body_set_param>`.
  1046. .. rst-class:: classref-item-separator
  1047. ----
  1048. .. _class_PhysicsServer2D_method_body_set_axis_velocity:
  1049. .. rst-class:: classref-method
  1050. void **body_set_axis_velocity** **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` axis_velocity **)**
  1051. Modifies the body's linear velocity so that its projection to the axis ``axis_velocity.normalized()`` is exactly ``axis_velocity.length()``. This is useful for jumping behavior.
  1052. .. rst-class:: classref-item-separator
  1053. ----
  1054. .. _class_PhysicsServer2D_method_body_set_collision_layer:
  1055. .. rst-class:: classref-method
  1056. void **body_set_collision_layer** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` layer **)**
  1057. Sets the physics layer or layers the body belongs to, via a bitmask.
  1058. .. rst-class:: classref-item-separator
  1059. ----
  1060. .. _class_PhysicsServer2D_method_body_set_collision_mask:
  1061. .. rst-class:: classref-method
  1062. void **body_set_collision_mask** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` mask **)**
  1063. Sets the physics layer or layers the body can collide with, via a bitmask.
  1064. .. rst-class:: classref-item-separator
  1065. ----
  1066. .. _class_PhysicsServer2D_method_body_set_collision_priority:
  1067. .. rst-class:: classref-method
  1068. void **body_set_collision_priority** **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` priority **)**
  1069. Sets the body's collision priority. This is used in the depenetration phase of :ref:`body_test_motion<class_PhysicsServer2D_method_body_test_motion>`. The higher the priority is, the lower the penetration into the body will be.
  1070. .. rst-class:: classref-item-separator
  1071. ----
  1072. .. _class_PhysicsServer2D_method_body_set_constant_force:
  1073. .. rst-class:: classref-method
  1074. void **body_set_constant_force** **(** :ref:`RID<class_RID>` body, :ref:`Vector2<class_Vector2>` force **)**
  1075. Sets the body's total constant positional force applied during each physics update.
  1076. See :ref:`body_add_constant_force<class_PhysicsServer2D_method_body_add_constant_force>` and :ref:`body_add_constant_central_force<class_PhysicsServer2D_method_body_add_constant_central_force>`.
  1077. .. rst-class:: classref-item-separator
  1078. ----
  1079. .. _class_PhysicsServer2D_method_body_set_constant_torque:
  1080. .. rst-class:: classref-method
  1081. void **body_set_constant_torque** **(** :ref:`RID<class_RID>` body, :ref:`float<class_float>` torque **)**
  1082. Sets the body's total constant rotational force applied during each physics update.
  1083. See :ref:`body_add_constant_torque<class_PhysicsServer2D_method_body_add_constant_torque>`.
  1084. .. rst-class:: classref-item-separator
  1085. ----
  1086. .. _class_PhysicsServer2D_method_body_set_continuous_collision_detection_mode:
  1087. .. rst-class:: classref-method
  1088. void **body_set_continuous_collision_detection_mode** **(** :ref:`RID<class_RID>` body, :ref:`CCDMode<enum_PhysicsServer2D_CCDMode>` mode **)**
  1089. Sets the continuous collision detection mode using one of the :ref:`CCDMode<enum_PhysicsServer2D_CCDMode>` constants.
  1090. Continuous collision detection tries to predict where a moving body would collide in between physics updates, instead of moving it and correcting its movement if it collided.
  1091. .. rst-class:: classref-item-separator
  1092. ----
  1093. .. _class_PhysicsServer2D_method_body_set_force_integration_callback:
  1094. .. rst-class:: classref-method
  1095. void **body_set_force_integration_callback** **(** :ref:`RID<class_RID>` body, :ref:`Callable<class_Callable>` callable, :ref:`Variant<class_Variant>` userdata=null **)**
  1096. Sets the function used to calculate physics for the body, if that body allows it (see :ref:`body_set_omit_force_integration<class_PhysicsServer2D_method_body_set_omit_force_integration>`).
  1097. The force integration function takes the following two parameters:
  1098. 1. a :ref:`PhysicsDirectBodyState2D<class_PhysicsDirectBodyState2D>` ``state``: used to retrieve and modify the body's state,
  1099. 2. a :ref:`Variant<class_Variant>` ``userdata``: optional user data.
  1100. \ **Note:** This callback is currently not called in Godot Physics.
  1101. .. rst-class:: classref-item-separator
  1102. ----
  1103. .. _class_PhysicsServer2D_method_body_set_max_contacts_reported:
  1104. .. rst-class:: classref-method
  1105. void **body_set_max_contacts_reported** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` amount **)**
  1106. Sets the maximum number of contacts that the body can report. If ``amount`` is greater than zero, then the body will keep track of at most this many contacts with other bodies.
  1107. .. rst-class:: classref-item-separator
  1108. ----
  1109. .. _class_PhysicsServer2D_method_body_set_mode:
  1110. .. rst-class:: classref-method
  1111. void **body_set_mode** **(** :ref:`RID<class_RID>` body, :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>` mode **)**
  1112. Sets the body's mode. See :ref:`BodyMode<enum_PhysicsServer2D_BodyMode>` for the list of available modes.
  1113. .. rst-class:: classref-item-separator
  1114. ----
  1115. .. _class_PhysicsServer2D_method_body_set_omit_force_integration:
  1116. .. rst-class:: classref-method
  1117. void **body_set_omit_force_integration** **(** :ref:`RID<class_RID>` body, :ref:`bool<class_bool>` enable **)**
  1118. Sets whether the body uses a callback function to calculate its own physics (see :ref:`body_set_force_integration_callback<class_PhysicsServer2D_method_body_set_force_integration_callback>`).
  1119. .. rst-class:: classref-item-separator
  1120. ----
  1121. .. _class_PhysicsServer2D_method_body_set_param:
  1122. .. rst-class:: classref-method
  1123. void **body_set_param** **(** :ref:`RID<class_RID>` body, :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` param, :ref:`Variant<class_Variant>` value **)**
  1124. Sets the value of the given body parameter. See :ref:`BodyParameter<enum_PhysicsServer2D_BodyParameter>` for the list of available parameters.
  1125. .. rst-class:: classref-item-separator
  1126. ----
  1127. .. _class_PhysicsServer2D_method_body_set_shape:
  1128. .. rst-class:: classref-method
  1129. void **body_set_shape** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx, :ref:`RID<class_RID>` shape **)**
  1130. Replaces the body's shape at the given index by another shape, while not affecting the ``transform``, ``disabled``, and one-way collision properties at the same index.
  1131. .. rst-class:: classref-item-separator
  1132. ----
  1133. .. _class_PhysicsServer2D_method_body_set_shape_as_one_way_collision:
  1134. .. rst-class:: classref-method
  1135. void **body_set_shape_as_one_way_collision** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` enable, :ref:`float<class_float>` margin **)**
  1136. Sets the one-way collision properties of the body's shape with the given index. If ``enable`` is ``true``, the one-way collision direction given by the shape's local upward axis ``body_get_shape_transform(body, shape_idx).y`` will be used to ignore collisions with the shape in the opposite direction, and to ensure depenetration of kinematic bodies happens in this direction.
  1137. .. rst-class:: classref-item-separator
  1138. ----
  1139. .. _class_PhysicsServer2D_method_body_set_shape_disabled:
  1140. .. rst-class:: classref-method
  1141. void **body_set_shape_disabled** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx, :ref:`bool<class_bool>` disabled **)**
  1142. Sets the disabled property of the body's shape with the given index. If ``disabled`` is ``true``, then the shape will be ignored in all collision detection.
  1143. .. rst-class:: classref-item-separator
  1144. ----
  1145. .. _class_PhysicsServer2D_method_body_set_shape_transform:
  1146. .. rst-class:: classref-method
  1147. void **body_set_shape_transform** **(** :ref:`RID<class_RID>` body, :ref:`int<class_int>` shape_idx, :ref:`Transform2D<class_Transform2D>` transform **)**
  1148. Sets the local transform matrix of the body's shape with the given index.
  1149. .. rst-class:: classref-item-separator
  1150. ----
  1151. .. _class_PhysicsServer2D_method_body_set_space:
  1152. .. rst-class:: classref-method
  1153. void **body_set_space** **(** :ref:`RID<class_RID>` body, :ref:`RID<class_RID>` space **)**
  1154. Adds the body to the given space, after removing the body from the previously assigned space (if any). If the body's mode is set to :ref:`BODY_MODE_RIGID<class_PhysicsServer2D_constant_BODY_MODE_RIGID>`, then adding the body to a space will have the following additional effects:
  1155. - If the parameter :ref:`BODY_PARAM_CENTER_OF_MASS<class_PhysicsServer2D_constant_BODY_PARAM_CENTER_OF_MASS>` has never been set explicitly, then the value of that parameter will be recalculated based on the body's shapes.
  1156. - If the parameter :ref:`BODY_PARAM_INERTIA<class_PhysicsServer2D_constant_BODY_PARAM_INERTIA>` is set to a value ``<= 0.0``, then the value of that parameter will be recalculated based on the body's shapes, mass, and center of mass.
  1157. \ **Note:** To remove a body from a space without immediately adding it back elsewhere, use ``PhysicsServer2D.body_set_space(body, RID())``.
  1158. .. rst-class:: classref-item-separator
  1159. ----
  1160. .. _class_PhysicsServer2D_method_body_set_state:
  1161. .. rst-class:: classref-method
  1162. void **body_set_state** **(** :ref:`RID<class_RID>` body, :ref:`BodyState<enum_PhysicsServer2D_BodyState>` state, :ref:`Variant<class_Variant>` value **)**
  1163. Sets the value of a body's state. See :ref:`BodyState<enum_PhysicsServer2D_BodyState>` for the list of available states.
  1164. \ **Note:** The state change doesn't take effect immediately. The state will change on the next physics frame.
  1165. .. rst-class:: classref-item-separator
  1166. ----
  1167. .. _class_PhysicsServer2D_method_body_test_motion:
  1168. .. rst-class:: classref-method
  1169. :ref:`bool<class_bool>` **body_test_motion** **(** :ref:`RID<class_RID>` body, :ref:`PhysicsTestMotionParameters2D<class_PhysicsTestMotionParameters2D>` parameters, :ref:`PhysicsTestMotionResult2D<class_PhysicsTestMotionResult2D>` result=null **)**
  1170. Returns ``true`` if a collision would result from moving the body along a motion vector from a given point in space. See :ref:`PhysicsTestMotionParameters2D<class_PhysicsTestMotionParameters2D>` for the available motion parameters. Optionally a :ref:`PhysicsTestMotionResult2D<class_PhysicsTestMotionResult2D>` object can be passed, which will be used to store the information about the resulting collision.
  1171. .. rst-class:: classref-item-separator
  1172. ----
  1173. .. _class_PhysicsServer2D_method_capsule_shape_create:
  1174. .. rst-class:: classref-method
  1175. :ref:`RID<class_RID>` **capsule_shape_create** **(** **)**
  1176. Creates a 2D capsule shape in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` to set the capsule's height and radius.
  1177. .. rst-class:: classref-item-separator
  1178. ----
  1179. .. _class_PhysicsServer2D_method_circle_shape_create:
  1180. .. rst-class:: classref-method
  1181. :ref:`RID<class_RID>` **circle_shape_create** **(** **)**
  1182. Creates a 2D circle shape in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` to set the circle's radius.
  1183. .. rst-class:: classref-item-separator
  1184. ----
  1185. .. _class_PhysicsServer2D_method_concave_polygon_shape_create:
  1186. .. rst-class:: classref-method
  1187. :ref:`RID<class_RID>` **concave_polygon_shape_create** **(** **)**
  1188. Creates a 2D concave polygon shape in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` to set the concave polygon's segments.
  1189. .. rst-class:: classref-item-separator
  1190. ----
  1191. .. _class_PhysicsServer2D_method_convex_polygon_shape_create:
  1192. .. rst-class:: classref-method
  1193. :ref:`RID<class_RID>` **convex_polygon_shape_create** **(** **)**
  1194. Creates a 2D convex polygon shape in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` to set the convex polygon's points.
  1195. .. rst-class:: classref-item-separator
  1196. ----
  1197. .. _class_PhysicsServer2D_method_damped_spring_joint_get_param:
  1198. .. rst-class:: classref-method
  1199. :ref:`float<class_float>` **damped_spring_joint_get_param** **(** :ref:`RID<class_RID>` joint, :ref:`DampedSpringParam<enum_PhysicsServer2D_DampedSpringParam>` param **)** |const|
  1200. Returns the value of the given damped spring joint parameter. See :ref:`DampedSpringParam<enum_PhysicsServer2D_DampedSpringParam>` for the list of available parameters.
  1201. .. rst-class:: classref-item-separator
  1202. ----
  1203. .. _class_PhysicsServer2D_method_damped_spring_joint_set_param:
  1204. .. rst-class:: classref-method
  1205. void **damped_spring_joint_set_param** **(** :ref:`RID<class_RID>` joint, :ref:`DampedSpringParam<enum_PhysicsServer2D_DampedSpringParam>` param, :ref:`float<class_float>` value **)**
  1206. Sets the value of the given damped spring joint parameter. See :ref:`DampedSpringParam<enum_PhysicsServer2D_DampedSpringParam>` for the list of available parameters.
  1207. .. rst-class:: classref-item-separator
  1208. ----
  1209. .. _class_PhysicsServer2D_method_free_rid:
  1210. .. rst-class:: classref-method
  1211. void **free_rid** **(** :ref:`RID<class_RID>` rid **)**
  1212. Destroys any of the objects created by PhysicsServer2D. If the :ref:`RID<class_RID>` passed is not one of the objects that can be created by PhysicsServer2D, an error will be printed to the console.
  1213. .. rst-class:: classref-item-separator
  1214. ----
  1215. .. _class_PhysicsServer2D_method_get_process_info:
  1216. .. rst-class:: classref-method
  1217. :ref:`int<class_int>` **get_process_info** **(** :ref:`ProcessInfo<enum_PhysicsServer2D_ProcessInfo>` process_info **)**
  1218. Returns information about the current state of the 2D physics engine. See :ref:`ProcessInfo<enum_PhysicsServer2D_ProcessInfo>` for the list of available states.
  1219. .. rst-class:: classref-item-separator
  1220. ----
  1221. .. _class_PhysicsServer2D_method_joint_clear:
  1222. .. rst-class:: classref-method
  1223. void **joint_clear** **(** :ref:`RID<class_RID>` joint **)**
  1224. Destroys the joint with the given :ref:`RID<class_RID>`, creates a new uninitialized joint, and makes the :ref:`RID<class_RID>` refer to this new joint.
  1225. .. rst-class:: classref-item-separator
  1226. ----
  1227. .. _class_PhysicsServer2D_method_joint_create:
  1228. .. rst-class:: classref-method
  1229. :ref:`RID<class_RID>` **joint_create** **(** **)**
  1230. Creates a 2D joint in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. To set the joint type, use :ref:`joint_make_damped_spring<class_PhysicsServer2D_method_joint_make_damped_spring>`, :ref:`joint_make_groove<class_PhysicsServer2D_method_joint_make_groove>` or :ref:`joint_make_pin<class_PhysicsServer2D_method_joint_make_pin>`. Use :ref:`joint_set_param<class_PhysicsServer2D_method_joint_set_param>` to set generic joint parameters.
  1231. .. rst-class:: classref-item-separator
  1232. ----
  1233. .. _class_PhysicsServer2D_method_joint_disable_collisions_between_bodies:
  1234. .. rst-class:: classref-method
  1235. void **joint_disable_collisions_between_bodies** **(** :ref:`RID<class_RID>` joint, :ref:`bool<class_bool>` disable **)**
  1236. Sets whether the bodies attached to the :ref:`Joint2D<class_Joint2D>` will collide with each other.
  1237. .. rst-class:: classref-item-separator
  1238. ----
  1239. .. _class_PhysicsServer2D_method_joint_get_param:
  1240. .. rst-class:: classref-method
  1241. :ref:`float<class_float>` **joint_get_param** **(** :ref:`RID<class_RID>` joint, :ref:`JointParam<enum_PhysicsServer2D_JointParam>` param **)** |const|
  1242. Returns the value of the given joint parameter. See :ref:`JointParam<enum_PhysicsServer2D_JointParam>` for the list of available parameters.
  1243. .. rst-class:: classref-item-separator
  1244. ----
  1245. .. _class_PhysicsServer2D_method_joint_get_type:
  1246. .. rst-class:: classref-method
  1247. :ref:`JointType<enum_PhysicsServer2D_JointType>` **joint_get_type** **(** :ref:`RID<class_RID>` joint **)** |const|
  1248. Returns the joint's type (see :ref:`JointType<enum_PhysicsServer2D_JointType>`).
  1249. .. rst-class:: classref-item-separator
  1250. ----
  1251. .. _class_PhysicsServer2D_method_joint_is_disabled_collisions_between_bodies:
  1252. .. rst-class:: classref-method
  1253. :ref:`bool<class_bool>` **joint_is_disabled_collisions_between_bodies** **(** :ref:`RID<class_RID>` joint **)** |const|
  1254. Returns whether the bodies attached to the :ref:`Joint2D<class_Joint2D>` will collide with each other.
  1255. .. rst-class:: classref-item-separator
  1256. ----
  1257. .. _class_PhysicsServer2D_method_joint_make_damped_spring:
  1258. .. rst-class:: classref-method
  1259. void **joint_make_damped_spring** **(** :ref:`RID<class_RID>` joint, :ref:`Vector2<class_Vector2>` anchor_a, :ref:`Vector2<class_Vector2>` anchor_b, :ref:`RID<class_RID>` body_a, :ref:`RID<class_RID>` body_b=RID() **)**
  1260. Makes the joint a damped spring joint, attached at the point ``anchor_a`` (given in global coordinates) on the body ``body_a`` and at the point ``anchor_b`` (given in global coordinates) on the body ``body_b``. To set the parameters which are specific to the damped spring, see :ref:`damped_spring_joint_set_param<class_PhysicsServer2D_method_damped_spring_joint_set_param>`.
  1261. .. rst-class:: classref-item-separator
  1262. ----
  1263. .. _class_PhysicsServer2D_method_joint_make_groove:
  1264. .. rst-class:: classref-method
  1265. void **joint_make_groove** **(** :ref:`RID<class_RID>` joint, :ref:`Vector2<class_Vector2>` groove1_a, :ref:`Vector2<class_Vector2>` groove2_a, :ref:`Vector2<class_Vector2>` anchor_b, :ref:`RID<class_RID>` body_a=RID(), :ref:`RID<class_RID>` body_b=RID() **)**
  1266. Makes the joint a groove joint.
  1267. .. rst-class:: classref-item-separator
  1268. ----
  1269. .. _class_PhysicsServer2D_method_joint_make_pin:
  1270. .. rst-class:: classref-method
  1271. void **joint_make_pin** **(** :ref:`RID<class_RID>` joint, :ref:`Vector2<class_Vector2>` anchor, :ref:`RID<class_RID>` body_a, :ref:`RID<class_RID>` body_b=RID() **)**
  1272. Makes the joint a pin joint. If ``body_b`` is ``RID()``, then ``body_a`` is pinned to the point ``anchor`` (given in global coordinates); otherwise, ``body_a`` is pinned to ``body_b`` at the point ``anchor`` (given in global coordinates). To set the parameters which are specific to the pin joint, see :ref:`pin_joint_set_param<class_PhysicsServer2D_method_pin_joint_set_param>`.
  1273. .. rst-class:: classref-item-separator
  1274. ----
  1275. .. _class_PhysicsServer2D_method_joint_set_param:
  1276. .. rst-class:: classref-method
  1277. void **joint_set_param** **(** :ref:`RID<class_RID>` joint, :ref:`JointParam<enum_PhysicsServer2D_JointParam>` param, :ref:`float<class_float>` value **)**
  1278. Sets the value of the given joint parameter. See :ref:`JointParam<enum_PhysicsServer2D_JointParam>` for the list of available parameters.
  1279. .. rst-class:: classref-item-separator
  1280. ----
  1281. .. _class_PhysicsServer2D_method_pin_joint_get_param:
  1282. .. rst-class:: classref-method
  1283. :ref:`float<class_float>` **pin_joint_get_param** **(** :ref:`RID<class_RID>` joint, :ref:`PinJointParam<enum_PhysicsServer2D_PinJointParam>` param **)** |const|
  1284. Returns the value of a pin joint parameter. See :ref:`PinJointParam<enum_PhysicsServer2D_PinJointParam>` for a list of available parameters.
  1285. .. rst-class:: classref-item-separator
  1286. ----
  1287. .. _class_PhysicsServer2D_method_pin_joint_set_param:
  1288. .. rst-class:: classref-method
  1289. void **pin_joint_set_param** **(** :ref:`RID<class_RID>` joint, :ref:`PinJointParam<enum_PhysicsServer2D_PinJointParam>` param, :ref:`float<class_float>` value **)**
  1290. Sets a pin joint parameter. See :ref:`PinJointParam<enum_PhysicsServer2D_PinJointParam>` for a list of available parameters.
  1291. .. rst-class:: classref-item-separator
  1292. ----
  1293. .. _class_PhysicsServer2D_method_rectangle_shape_create:
  1294. .. rst-class:: classref-method
  1295. :ref:`RID<class_RID>` **rectangle_shape_create** **(** **)**
  1296. Creates a 2D rectangle shape in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` to set the rectangle's half-extents.
  1297. .. rst-class:: classref-item-separator
  1298. ----
  1299. .. _class_PhysicsServer2D_method_segment_shape_create:
  1300. .. rst-class:: classref-method
  1301. :ref:`RID<class_RID>` **segment_shape_create** **(** **)**
  1302. Creates a 2D segment shape in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` to set the segment's start and end points.
  1303. .. rst-class:: classref-item-separator
  1304. ----
  1305. .. _class_PhysicsServer2D_method_separation_ray_shape_create:
  1306. .. rst-class:: classref-method
  1307. :ref:`RID<class_RID>` **separation_ray_shape_create** **(** **)**
  1308. Creates a 2D separation ray shape in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` to set the shape's ``length`` and ``slide_on_slope`` properties.
  1309. .. rst-class:: classref-item-separator
  1310. ----
  1311. .. _class_PhysicsServer2D_method_set_active:
  1312. .. rst-class:: classref-method
  1313. void **set_active** **(** :ref:`bool<class_bool>` active **)**
  1314. Activates or deactivates the 2D physics server. If ``active`` is ``false``, then the physics server will not do anything in its physics step.
  1315. .. rst-class:: classref-item-separator
  1316. ----
  1317. .. _class_PhysicsServer2D_method_shape_get_data:
  1318. .. rst-class:: classref-method
  1319. :ref:`Variant<class_Variant>` **shape_get_data** **(** :ref:`RID<class_RID>` shape **)** |const|
  1320. Returns the shape data that defines the configuration of the shape, such as the half-extents of a rectangle or the segments of a concave shape. See :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` for the precise format of this data in each case.
  1321. .. rst-class:: classref-item-separator
  1322. ----
  1323. .. _class_PhysicsServer2D_method_shape_get_type:
  1324. .. rst-class:: classref-method
  1325. :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>` **shape_get_type** **(** :ref:`RID<class_RID>` shape **)** |const|
  1326. Returns the shape's type (see :ref:`ShapeType<enum_PhysicsServer2D_ShapeType>`).
  1327. .. rst-class:: classref-item-separator
  1328. ----
  1329. .. _class_PhysicsServer2D_method_shape_set_data:
  1330. .. rst-class:: classref-method
  1331. void **shape_set_data** **(** :ref:`RID<class_RID>` shape, :ref:`Variant<class_Variant>` data **)**
  1332. Sets the shape data that defines the configuration of the shape. The ``data`` to be passed depends on the shape's type (see :ref:`shape_get_type<class_PhysicsServer2D_method_shape_get_type>`):
  1333. - :ref:`SHAPE_WORLD_BOUNDARY<class_PhysicsServer2D_constant_SHAPE_WORLD_BOUNDARY>`: an array of length two containing a :ref:`Vector2<class_Vector2>` ``normal`` direction and a ``float`` distance ``d``,
  1334. - :ref:`SHAPE_SEPARATION_RAY<class_PhysicsServer2D_constant_SHAPE_SEPARATION_RAY>`: a dictionary containing the key ``length`` with a ``float`` value and the key ``slide_on_slope`` with a ``bool`` value,
  1335. - :ref:`SHAPE_SEGMENT<class_PhysicsServer2D_constant_SHAPE_SEGMENT>`: a :ref:`Rect2<class_Rect2>` ``rect`` containing the first point of the segment in ``rect.position`` and the second point of the segment in ``rect.size``,
  1336. - :ref:`SHAPE_CIRCLE<class_PhysicsServer2D_constant_SHAPE_CIRCLE>`: a ``float`` ``radius``,
  1337. - :ref:`SHAPE_RECTANGLE<class_PhysicsServer2D_constant_SHAPE_RECTANGLE>`: a :ref:`Vector2<class_Vector2>` ``half_extents``,
  1338. - :ref:`SHAPE_CAPSULE<class_PhysicsServer2D_constant_SHAPE_CAPSULE>`: an array of length two (or a :ref:`Vector2<class_Vector2>`) containing a ``float`` ``height`` and a ``float`` ``radius``,
  1339. - :ref:`SHAPE_CONVEX_POLYGON<class_PhysicsServer2D_constant_SHAPE_CONVEX_POLYGON>`: either a :ref:`PackedVector2Array<class_PackedVector2Array>` of points defining a convex polygon in counterclockwise order (the clockwise outward normal of each segment formed by consecutive points is calculated internally), or a :ref:`PackedFloat32Array<class_PackedFloat32Array>` of length divisible by four so that every 4-tuple of ``float``\ s contains the coordinates of a point followed by the coordinates of the clockwise outward normal vector to the segment between the current point and the next point,
  1340. - :ref:`SHAPE_CONCAVE_POLYGON<class_PhysicsServer2D_constant_SHAPE_CONCAVE_POLYGON>`: a :ref:`PackedVector2Array<class_PackedVector2Array>` of length divisible by two (each pair of points forms one segment).
  1341. \ **Warning:** In the case of :ref:`SHAPE_CONVEX_POLYGON<class_PhysicsServer2D_constant_SHAPE_CONVEX_POLYGON>`, this method does not check if the points supplied actually form a convex polygon (unlike the :ref:`CollisionPolygon2D.polygon<class_CollisionPolygon2D_property_polygon>` property).
  1342. .. rst-class:: classref-item-separator
  1343. ----
  1344. .. _class_PhysicsServer2D_method_space_create:
  1345. .. rst-class:: classref-method
  1346. :ref:`RID<class_RID>` **space_create** **(** **)**
  1347. Creates a 2D space in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. A space contains bodies and areas, and controls the stepping of the physics simulation of the objects in it.
  1348. .. rst-class:: classref-item-separator
  1349. ----
  1350. .. _class_PhysicsServer2D_method_space_get_direct_state:
  1351. .. rst-class:: classref-method
  1352. :ref:`PhysicsDirectSpaceState2D<class_PhysicsDirectSpaceState2D>` **space_get_direct_state** **(** :ref:`RID<class_RID>` space **)**
  1353. Returns the state of a space, a :ref:`PhysicsDirectSpaceState2D<class_PhysicsDirectSpaceState2D>`. This object can be used for collision/intersection queries.
  1354. .. rst-class:: classref-item-separator
  1355. ----
  1356. .. _class_PhysicsServer2D_method_space_get_param:
  1357. .. rst-class:: classref-method
  1358. :ref:`float<class_float>` **space_get_param** **(** :ref:`RID<class_RID>` space, :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` param **)** |const|
  1359. Returns the value of the given space parameter. See :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` for the list of available parameters.
  1360. .. rst-class:: classref-item-separator
  1361. ----
  1362. .. _class_PhysicsServer2D_method_space_is_active:
  1363. .. rst-class:: classref-method
  1364. :ref:`bool<class_bool>` **space_is_active** **(** :ref:`RID<class_RID>` space **)** |const|
  1365. Returns ``true`` if the space is active.
  1366. .. rst-class:: classref-item-separator
  1367. ----
  1368. .. _class_PhysicsServer2D_method_space_set_active:
  1369. .. rst-class:: classref-method
  1370. void **space_set_active** **(** :ref:`RID<class_RID>` space, :ref:`bool<class_bool>` active **)**
  1371. Activates or deactivates the space. If ``active`` is ``false``, then the physics server will not do anything with this space in its physics step.
  1372. .. rst-class:: classref-item-separator
  1373. ----
  1374. .. _class_PhysicsServer2D_method_space_set_param:
  1375. .. rst-class:: classref-method
  1376. void **space_set_param** **(** :ref:`RID<class_RID>` space, :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` param, :ref:`float<class_float>` value **)**
  1377. Sets the value of the given space parameter. See :ref:`SpaceParameter<enum_PhysicsServer2D_SpaceParameter>` for the list of available parameters.
  1378. .. rst-class:: classref-item-separator
  1379. ----
  1380. .. _class_PhysicsServer2D_method_world_boundary_shape_create:
  1381. .. rst-class:: classref-method
  1382. :ref:`RID<class_RID>` **world_boundary_shape_create** **(** **)**
  1383. Creates a 2D world boundary shape in the physics server, and returns the :ref:`RID<class_RID>` that identifies it. Use :ref:`shape_set_data<class_PhysicsServer2D_method_shape_set_data>` to set the shape's normal direction and distance properties.
  1384. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  1385. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  1386. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  1387. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  1388. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  1389. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  1390. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`