Skip to content
0.2.0-dev Download ZIP
1245 lines ·70.3 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="PhysicsServer2D" inherits="Object" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A server interface for low-level 2D physics access.
5 </brief_description>
6 <description>
7 PhysicsServer2D is the server responsible for all 2D physics. It can directly create and manipulate all physics objects:
8 - A [i]space[/i] 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.
9 - A [i]shape[/i] 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.
10 - A [i]body[/i] 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.
11 - An [i]area[/i] 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.
12 - A [i]joint[/i] 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.
13 Physics objects in [PhysicsServer2D] may be created and manipulated independently; they do not have to be tied to nodes in the scene tree.
14 [b]Note:[/b] 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.
15 </description>
16 <tutorials>
17 </tutorials>
18 <methods>
19 <method name="area_add_shape">
20 <return type="void" />
21 <param index="0" name="area" type="RID" />
22 <param index="1" name="shape" type="RID" />
23 <param index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)" />
24 <param index="3" name="disabled" type="bool" default="false" />
25 <description>
26 Adds a shape to the area, with the given local transform. The shape (together with its [param transform] and [param disabled] properties) is added to an array of shapes, and the shapes of an area are usually referenced by their index in this array.
27 </description>
28 </method>
29 <method name="area_attach_canvas_instance_id">
30 <return type="void" />
31 <param index="0" name="area" type="RID" />
32 <param index="1" name="id" type="int" />
33 <description>
34 Attaches the [code]ObjectID[/code] of a canvas to the area. Use [method Object.get_instance_id] to get the [code]ObjectID[/code] of a [CanvasLayer].
35 </description>
36 </method>
37 <method name="area_attach_object_instance_id">
38 <return type="void" />
39 <param index="0" name="area" type="RID" />
40 <param index="1" name="id" type="int" />
41 <description>
42 Attaches the [code]ObjectID[/code] of an [Object] to the area. Use [method Object.get_instance_id] to get the [code]ObjectID[/code] of a [CollisionObject2D].
43 </description>
44 </method>
45 <method name="area_clear_shapes">
46 <return type="void" />
47 <param index="0" name="area" type="RID" />
48 <description>
49 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.
50 </description>
51 </method>
52 <method name="area_create">
53 <return type="RID" />
54 <description>
55 Creates a 2D area object in the physics server, and returns the [RID] that identifies it. The default settings for the created area include a collision layer and mask set to [code]1[/code], and [code]monitorable[/code] set to [code]false[/code].
56 Use [method area_add_shape] to add shapes to it, use [method area_set_transform] to set its transform, and use [method area_set_space] to add the area to a space. If you want the area to be detectable use [method area_set_monitorable].
57 </description>
58 </method>
59 <method name="area_get_canvas_instance_id" qualifiers="const">
60 <return type="int" />
61 <param index="0" name="area" type="RID" />
62 <description>
63 Returns the [code]ObjectID[/code] of the canvas attached to the area. Use [method @GlobalScope.instance_from_id] to retrieve a [CanvasLayer] from a nonzero [code]ObjectID[/code].
64 </description>
65 </method>
66 <method name="area_get_collision_layer" qualifiers="const">
67 <return type="int" />
68 <param index="0" name="area" type="RID" />
69 <description>
70 Returns the physics layer or layers the area belongs to, as a bitmask.
71 </description>
72 </method>
73 <method name="area_get_collision_mask" qualifiers="const">
74 <return type="int" />
75 <param index="0" name="area" type="RID" />
76 <description>
77 Returns the physics layer or layers the area can contact with, as a bitmask.
78 </description>
79 </method>
80 <method name="area_get_object_instance_id" qualifiers="const">
81 <return type="int" />
82 <param index="0" name="area" type="RID" />
83 <description>
84 Returns the [code]ObjectID[/code] attached to the area. Use [method @GlobalScope.instance_from_id] to retrieve an [Object] from a nonzero [code]ObjectID[/code].
85 </description>
86 </method>
87 <method name="area_get_param" qualifiers="const">
88 <return type="Variant" />
89 <param index="0" name="area" type="RID" />
90 <param index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter" />
91 <description>
92 Returns the value of the given area parameter.
93 </description>
94 </method>
95 <method name="area_get_shape" qualifiers="const">
96 <return type="RID" />
97 <param index="0" name="area" type="RID" />
98 <param index="1" name="shape_idx" type="int" />
99 <description>
100 Returns the [RID] of the shape with the given index in the area's array of shapes.
101 </description>
102 </method>
103 <method name="area_get_shape_count" qualifiers="const">
104 <return type="int" />
105 <param index="0" name="area" type="RID" />
106 <description>
107 Returns the number of shapes added to the area.
108 </description>
109 </method>
110 <method name="area_get_shape_transform" qualifiers="const">
111 <return type="Transform2D" />
112 <param index="0" name="area" type="RID" />
113 <param index="1" name="shape_idx" type="int" />
114 <description>
115 Returns the local transform matrix of the shape with the given index in the area's array of shapes.
116 </description>
117 </method>
118 <method name="area_get_space" qualifiers="const">
119 <return type="RID" />
120 <param index="0" name="area" type="RID" />
121 <description>
122 Returns the [RID] of the space assigned to the area. Returns an empty [RID] if no space is assigned.
123 </description>
124 </method>
125 <method name="area_get_transform" qualifiers="const">
126 <return type="Transform2D" />
127 <param index="0" name="area" type="RID" />
128 <description>
129 Returns the transform matrix of the area.
130 </description>
131 </method>
132 <method name="area_remove_shape">
133 <return type="void" />
134 <param index="0" name="area" type="RID" />
135 <param index="1" name="shape_idx" type="int" />
136 <description>
137 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 [param shape_idx] will have their index decreased by one.
138 </description>
139 </method>
140 <method name="area_set_area_monitor_callback">
141 <return type="void" />
142 <param index="0" name="area" type="RID" />
143 <param index="1" name="callback" type="Callable" />
144 <description>
145 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:
146 1. an integer [code]status[/code]: either [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED] depending on whether the other area's shape entered or exited the area,
147 2. an [RID] [code]area_rid[/code]: the [RID] of the other area that entered or exited the area,
148 3. an integer [code]instance_id[/code]: the [code]ObjectID[/code] attached to the other area,
149 4. an integer [code]area_shape_idx[/code]: the index of the shape of the other area that entered or exited the area,
150 5. an integer [code]self_shape_idx[/code]: the index of the shape of the area where the other area entered or exited.
151 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.
152 </description>
153 </method>
154 <method name="area_set_collision_layer">
155 <return type="void" />
156 <param index="0" name="area" type="RID" />
157 <param index="1" name="layer" type="int" />
158 <description>
159 Assigns the area to one or many physics layers, via a bitmask.
160 </description>
161 </method>
162 <method name="area_set_collision_mask">
163 <return type="void" />
164 <param index="0" name="area" type="RID" />
165 <param index="1" name="mask" type="int" />
166 <description>
167 Sets which physics layers the area will monitor, via a bitmask.
168 </description>
169 </method>
170 <method name="area_set_monitor_callback">
171 <return type="void" />
172 <param index="0" name="area" type="RID" />
173 <param index="1" name="callback" type="Callable" />
174 <description>
175 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:
176 1. an integer [code]status[/code]: either [constant AREA_BODY_ADDED] or [constant AREA_BODY_REMOVED] depending on whether the other body shape entered or exited the area,
177 2. an [RID] [code]body_rid[/code]: the [RID] of the body that entered or exited the area,
178 3. an integer [code]instance_id[/code]: the [code]ObjectID[/code] attached to the body,
179 4. an integer [code]body_shape_idx[/code]: the index of the shape of the body that entered or exited the area,
180 5. an integer [code]self_shape_idx[/code]: the index of the shape of the area where the body entered or exited.
181 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.
182 </description>
183 </method>
184 <method name="area_set_monitorable">
185 <return type="void" />
186 <param index="0" name="area" type="RID" />
187 <param index="1" name="monitorable" type="bool" />
188 <description>
189 Sets whether the area is monitorable or not. If [param monitorable] is [code]true[/code], the area monitoring callback of other areas will be called when this area enters or exits them.
190 </description>
191 </method>
192 <method name="area_set_param">
193 <return type="void" />
194 <param index="0" name="area" type="RID" />
195 <param index="1" name="param" type="int" enum="PhysicsServer2D.AreaParameter" />
196 <param index="2" name="value" type="Variant" />
197 <description>
198 Sets the value of the given area parameter.
199 </description>
200 </method>
201 <method name="area_set_shape">
202 <return type="void" />
203 <param index="0" name="area" type="RID" />
204 <param index="1" name="shape_idx" type="int" />
205 <param index="2" name="shape" type="RID" />
206 <description>
207 Replaces the area's shape at the given index by another shape, while not affecting the [code]transform[/code] and [code]disabled[/code] properties at the same index.
208 </description>
209 </method>
210 <method name="area_set_shape_disabled">
211 <return type="void" />
212 <param index="0" name="area" type="RID" />
213 <param index="1" name="shape_idx" type="int" />
214 <param index="2" name="disabled" type="bool" />
215 <description>
216 Sets the disabled property of the area's shape with the given index. If [param disabled] is [code]true[/code], then the shape will not detect any other shapes entering or exiting it.
217 </description>
218 </method>
219 <method name="area_set_shape_transform">
220 <return type="void" />
221 <param index="0" name="area" type="RID" />
222 <param index="1" name="shape_idx" type="int" />
223 <param index="2" name="transform" type="Transform2D" />
224 <description>
225 Sets the local transform matrix of the area's shape with the given index.
226 </description>
227 </method>
228 <method name="area_set_space">
229 <return type="void" />
230 <param index="0" name="area" type="RID" />
231 <param index="1" name="space" type="RID" />
232 <description>
233 Adds the area to the given space, after removing the area from the previously assigned space (if any).
234 [b]Note:[/b] To remove an area from a space without immediately adding it back elsewhere, use [code]PhysicsServer2D.area_set_space(area, RID())[/code].
235 </description>
236 </method>
237 <method name="area_set_transform">
238 <return type="void" />
239 <param index="0" name="area" type="RID" />
240 <param index="1" name="transform" type="Transform2D" />
241 <description>
242 Sets the transform matrix of the area.
243 </description>
244 </method>
245 <method name="body_add_collision_exception">
246 <return type="void" />
247 <param index="0" name="body" type="RID" />
248 <param index="1" name="excepted_body" type="RID" />
249 <description>
250 Adds [param excepted_body] to the body's list of collision exceptions, so that collisions with it are ignored.
251 </description>
252 </method>
253 <method name="body_add_constant_central_force">
254 <return type="void" />
255 <param index="0" name="body" type="RID" />
256 <param index="1" name="force" type="Vector2" />
257 <description>
258 Adds a constant directional force to the body. The force does not affect rotation. The force remains applied over time until cleared with [code]PhysicsServer2D.body_set_constant_force(body, Vector2(0, 0))[/code].
259 This is equivalent to using [method body_add_constant_force] at the body's center of mass.
260 </description>
261 </method>
262 <method name="body_add_constant_force">
263 <return type="void" />
264 <param index="0" name="body" type="RID" />
265 <param index="1" name="force" type="Vector2" />
266 <param index="2" name="position" type="Vector2" default="Vector2(0, 0)" />
267 <description>
268 Adds a constant positioned force to the body. The force can affect rotation if [param position] is different from the body's center of mass. The force remains applied over time until cleared with [code]PhysicsServer2D.body_set_constant_force(body, Vector2(0, 0))[/code].
269 [param position] is the offset from the body origin in global coordinates.
270 </description>
271 </method>
272 <method name="body_add_constant_torque">
273 <return type="void" />
274 <param index="0" name="body" type="RID" />
275 <param index="1" name="torque" type="float" />
276 <description>
277 Adds a constant rotational force to the body. The force does not affect position. The force remains applied over time until cleared with [code]PhysicsServer2D.body_set_constant_torque(body, 0)[/code].
278 </description>
279 </method>
280 <method name="body_add_shape">
281 <return type="void" />
282 <param index="0" name="body" type="RID" />
283 <param index="1" name="shape" type="RID" />
284 <param index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)" />
285 <param index="3" name="disabled" type="bool" default="false" />
286 <description>
287 Adds a shape to the area, with the given local transform. The shape (together with its [param transform] and [param disabled] properties) is added to an array of shapes, and the shapes of a body are usually referenced by their index in this array.
288 </description>
289 </method>
290 <method name="body_apply_central_force">
291 <return type="void" />
292 <param index="0" name="body" type="RID" />
293 <param index="1" name="force" type="Vector2" />
294 <description>
295 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.
296 This is equivalent to using [method body_apply_force] at the body's center of mass.
297 </description>
298 </method>
299 <method name="body_apply_central_impulse">
300 <return type="void" />
301 <param index="0" name="body" type="RID" />
302 <param index="1" name="impulse" type="Vector2" />
303 <description>
304 Applies a directional impulse to the body, at the body's center of mass. The impulse does not affect rotation.
305 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).
306 This is equivalent to using [method body_apply_impulse] at the body's center of mass.
307 </description>
308 </method>
309 <method name="body_apply_force">
310 <return type="void" />
311 <param index="0" name="body" type="RID" />
312 <param index="1" name="force" type="Vector2" />
313 <param index="2" name="position" type="Vector2" default="Vector2(0, 0)" />
314 <description>
315 Applies a positioned force to the body. The force can affect rotation if [param position] is different from the body's center of mass. A force is time dependent and meant to be applied every physics update.
316 [param position] is the offset from the body origin in global coordinates.
317 </description>
318 </method>
319 <method name="body_apply_impulse">
320 <return type="void" />
321 <param index="0" name="body" type="RID" />
322 <param index="1" name="impulse" type="Vector2" />
323 <param index="2" name="position" type="Vector2" default="Vector2(0, 0)" />
324 <description>
325 Applies a positioned impulse to the body. The impulse can affect rotation if [param position] is different from the body's center of mass.
326 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).
327 [param position] is the offset from the body origin in global coordinates.
328 </description>
329 </method>
330 <method name="body_apply_torque">
331 <return type="void" />
332 <param index="0" name="body" type="RID" />
333 <param index="1" name="torque" type="float" />
334 <description>
335 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.
336 </description>
337 </method>
338 <method name="body_apply_torque_impulse">
339 <return type="void" />
340 <param index="0" name="body" type="RID" />
341 <param index="1" name="impulse" type="float" />
342 <description>
343 Applies a rotational impulse to the body. The impulse does not affect position.
344 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).
345 </description>
346 </method>
347 <method name="body_attach_canvas_instance_id">
348 <return type="void" />
349 <param index="0" name="body" type="RID" />
350 <param index="1" name="id" type="int" />
351 <description>
352 Attaches the [code]ObjectID[/code] of a canvas to the body. Use [method Object.get_instance_id] to get the [code]ObjectID[/code] of a [CanvasLayer].
353 </description>
354 </method>
355 <method name="body_attach_object_instance_id">
356 <return type="void" />
357 <param index="0" name="body" type="RID" />
358 <param index="1" name="id" type="int" />
359 <description>
360 Attaches the [code]ObjectID[/code] of an [Object] to the body. Use [method Object.get_instance_id] to get the [code]ObjectID[/code] of a [CollisionObject2D].
361 </description>
362 </method>
363 <method name="body_clear_shapes">
364 <return type="void" />
365 <param index="0" name="body" type="RID" />
366 <description>
367 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.
368 </description>
369 </method>
370 <method name="body_create">
371 <return type="RID" />
372 <description>
373 Creates a 2D body object in the physics server, and returns the [RID] that identifies it. The default settings for the created area include a collision layer and mask set to [code]1[/code], and body mode set to [constant BODY_MODE_RIGID].
374 Use [method body_add_shape] to add shapes to it, use [method body_set_state] to set its transform, and use [method body_set_space] to add the body to a space.
375 </description>
376 </method>
377 <method name="body_get_canvas_instance_id" qualifiers="const">
378 <return type="int" />
379 <param index="0" name="body" type="RID" />
380 <description>
381 Returns the [code]ObjectID[/code] of the canvas attached to the body. Use [method @GlobalScope.instance_from_id] to retrieve a [CanvasLayer] from a nonzero [code]ObjectID[/code].
382 </description>
383 </method>
384 <method name="body_get_collision_layer" qualifiers="const">
385 <return type="int" />
386 <param index="0" name="body" type="RID" />
387 <description>
388 Returns the physics layer or layers the body belongs to, as a bitmask.
389 </description>
390 </method>
391 <method name="body_get_collision_mask" qualifiers="const">
392 <return type="int" />
393 <param index="0" name="body" type="RID" />
394 <description>
395 Returns the physics layer or layers the body can collide with, as a bitmask.
396 </description>
397 </method>
398 <method name="body_get_collision_priority" qualifiers="const">
399 <return type="float" />
400 <param index="0" name="body" type="RID" />
401 <description>
402 Returns the body's collision priority. This is used in the depenetration phase of [method body_test_motion]. The higher the priority is, the lower the penetration into the body will be.
403 </description>
404 </method>
405 <method name="body_get_constant_force" qualifiers="const">
406 <return type="Vector2" />
407 <param index="0" name="body" type="RID" />
408 <description>
409 Returns the body's total constant positional force applied during each physics update.
410 See [method body_add_constant_force] and [method body_add_constant_central_force].
411 </description>
412 </method>
413 <method name="body_get_constant_torque" qualifiers="const">
414 <return type="float" />
415 <param index="0" name="body" type="RID" />
416 <description>
417 Returns the body's total constant rotational force applied during each physics update.
418 See [method body_add_constant_torque].
419 </description>
420 </method>
421 <method name="body_get_continuous_collision_detection_mode" qualifiers="const">
422 <return type="int" enum="PhysicsServer2D.CCDMode" />
423 <param index="0" name="body" type="RID" />
424 <description>
425 Returns the body's continuous collision detection mode.
426 </description>
427 </method>
428 <method name="body_get_direct_state">
429 <return type="PhysicsDirectBodyState2D" />
430 <param index="0" name="body" type="RID" />
431 <description>
432 Returns the [PhysicsDirectBodyState2D] of the body. Returns [code]null[/code] if the body is destroyed or not assigned to a space.
433 </description>
434 </method>
435 <method name="body_get_max_contacts_reported" qualifiers="const">
436 <return type="int" />
437 <param index="0" name="body" type="RID" />
438 <description>
439 Returns the maximum number of contacts that the body can report. See [method body_set_max_contacts_reported].
440 </description>
441 </method>
442 <method name="body_get_mode" qualifiers="const">
443 <return type="int" enum="PhysicsServer2D.BodyMode" />
444 <param index="0" name="body" type="RID" />
445 <description>
446 Returns the body's mode.
447 </description>
448 </method>
449 <method name="body_get_object_instance_id" qualifiers="const">
450 <return type="int" />
451 <param index="0" name="body" type="RID" />
452 <description>
453 Returns the [code]ObjectID[/code] attached to the body. Use [method @GlobalScope.instance_from_id] to retrieve an [Object] from a nonzero [code]ObjectID[/code].
454 </description>
455 </method>
456 <method name="body_get_param" qualifiers="const">
457 <return type="Variant" />
458 <param index="0" name="body" type="RID" />
459 <param index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter" />
460 <description>
461 Returns the value of the given body parameter.
462 </description>
463 </method>
464 <method name="body_get_shape" qualifiers="const">
465 <return type="RID" />
466 <param index="0" name="body" type="RID" />
467 <param index="1" name="shape_idx" type="int" />
468 <description>
469 Returns the [RID] of the shape with the given index in the body's array of shapes.
470 </description>
471 </method>
472 <method name="body_get_shape_count" qualifiers="const">
473 <return type="int" />
474 <param index="0" name="body" type="RID" />
475 <description>
476 Returns the number of shapes added to the body.
477 </description>
478 </method>
479 <method name="body_get_shape_transform" qualifiers="const">
480 <return type="Transform2D" />
481 <param index="0" name="body" type="RID" />
482 <param index="1" name="shape_idx" type="int" />
483 <description>
484 Returns the local transform matrix of the shape with the given index in the area's array of shapes.
485 </description>
486 </method>
487 <method name="body_get_space" qualifiers="const">
488 <return type="RID" />
489 <param index="0" name="body" type="RID" />
490 <description>
491 Returns the [RID] of the space assigned to the body. Returns an empty [RID] if no space is assigned.
492 </description>
493 </method>
494 <method name="body_get_state" qualifiers="const">
495 <return type="Variant" />
496 <param index="0" name="body" type="RID" />
497 <param index="1" name="state" type="int" enum="PhysicsServer2D.BodyState" />
498 <description>
499 Returns the value of the given state of the body.
500 </description>
501 </method>
502 <method name="body_is_omitting_force_integration" qualifiers="const">
503 <return type="bool" />
504 <param index="0" name="body" type="RID" />
505 <description>
506 Returns [code]true[/code] if the body is omitting the standard force integration. See [method body_set_omit_force_integration].
507 </description>
508 </method>
509 <method name="body_remove_collision_exception">
510 <return type="void" />
511 <param index="0" name="body" type="RID" />
512 <param index="1" name="excepted_body" type="RID" />
513 <description>
514 Removes [param excepted_body] from the body's list of collision exceptions, so that collisions with it are no longer ignored.
515 </description>
516 </method>
517 <method name="body_remove_shape">
518 <return type="void" />
519 <param index="0" name="body" type="RID" />
520 <param index="1" name="shape_idx" type="int" />
521 <description>
522 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 [param shape_idx] will have their index decreased by one.
523 </description>
524 </method>
525 <method name="body_reset_mass_properties">
526 <return type="void" />
527 <param index="0" name="body" type="RID" />
528 <description>
529 Restores the default inertia and center of mass of the body based on its shapes. This undoes any custom values previously set using [method body_set_param].
530 </description>
531 </method>
532 <method name="body_set_axis_velocity">
533 <return type="void" />
534 <param index="0" name="body" type="RID" />
535 <param index="1" name="axis_velocity" type="Vector2" />
536 <description>
537 Modifies the body's linear velocity so that its projection to the axis [code]axis_velocity.normalized()[/code] is exactly [code]axis_velocity.length()[/code]. This is useful for jumping behavior.
538 </description>
539 </method>
540 <method name="body_set_collision_layer">
541 <return type="void" />
542 <param index="0" name="body" type="RID" />
543 <param index="1" name="layer" type="int" />
544 <description>
545 Sets the physics layer or layers the body belongs to, via a bitmask.
546 </description>
547 </method>
548 <method name="body_set_collision_mask">
549 <return type="void" />
550 <param index="0" name="body" type="RID" />
551 <param index="1" name="mask" type="int" />
552 <description>
553 Sets the physics layer or layers the body can collide with, via a bitmask.
554 </description>
555 </method>
556 <method name="body_set_collision_priority">
557 <return type="void" />
558 <param index="0" name="body" type="RID" />
559 <param index="1" name="priority" type="float" />
560 <description>
561 Sets the body's collision priority. This is used in the depenetration phase of [method body_test_motion]. The higher the priority is, the lower the penetration into the body will be.
562 </description>
563 </method>
564 <method name="body_set_constant_force">
565 <return type="void" />
566 <param index="0" name="body" type="RID" />
567 <param index="1" name="force" type="Vector2" />
568 <description>
569 Sets the body's total constant positional force applied during each physics update.
570 See [method body_add_constant_force] and [method body_add_constant_central_force].
571 </description>
572 </method>
573 <method name="body_set_constant_torque">
574 <return type="void" />
575 <param index="0" name="body" type="RID" />
576 <param index="1" name="torque" type="float" />
577 <description>
578 Sets the body's total constant rotational force applied during each physics update.
579 See [method body_add_constant_torque].
580 </description>
581 </method>
582 <method name="body_set_continuous_collision_detection_mode">
583 <return type="void" />
584 <param index="0" name="body" type="RID" />
585 <param index="1" name="mode" type="int" enum="PhysicsServer2D.CCDMode" />
586 <description>
587 Sets the continuous collision detection mode.
588 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.
589 </description>
590 </method>
591 <method name="body_set_force_integration_callback">
592 <return type="void" />
593 <param index="0" name="body" type="RID" />
594 <param index="1" name="callable" type="Callable" />
595 <param index="2" name="userdata" type="Variant" default="null" />
596 <description>
597 Sets the body's custom force integration callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()[/code]) to clear the custom callback.
598 The function [param callable] will be called every physics tick, before the standard force integration (see [method body_set_omit_force_integration]). It can be used for example to update the body's linear and angular velocity based on contact with other bodies.
599 If [param userdata] is not [code]null[/code], the function [param callable] must take the following two parameters:
600 1. [code]state[/code]: a [PhysicsDirectBodyState2D] used to retrieve and modify the body's state,
601 2. [code skip-lint]userdata[/code]: a [Variant]; its value will be the [param userdata] passed into this method.
602 If [param userdata] is [code]null[/code], then [param callable] must take only the [code]state[/code] parameter.
603 </description>
604 </method>
605 <method name="body_set_max_contacts_reported">
606 <return type="void" />
607 <param index="0" name="body" type="RID" />
608 <param index="1" name="amount" type="int" />
609 <description>
610 Sets the maximum number of contacts that the body can report. If [param amount] is greater than zero, then the body will keep track of at most this many contacts with other bodies.
611 </description>
612 </method>
613 <method name="body_set_mode">
614 <return type="void" />
615 <param index="0" name="body" type="RID" />
616 <param index="1" name="mode" type="int" enum="PhysicsServer2D.BodyMode" />
617 <description>
618 Sets the body's mode.
619 </description>
620 </method>
621 <method name="body_set_omit_force_integration">
622 <return type="void" />
623 <param index="0" name="body" type="RID" />
624 <param index="1" name="enable" type="bool" />
625 <description>
626 Sets whether the body omits the standard force integration. If [param enable] is [code]true[/code], the body will not automatically use applied forces, torques, and damping to update the body's linear and angular velocity. In this case, [method body_set_force_integration_callback] can be used to manually update the linear and angular velocity instead.
627 This method is called when the property [member RigidBody2D.custom_integrator] is set.
628 </description>
629 </method>
630 <method name="body_set_param">
631 <return type="void" />
632 <param index="0" name="body" type="RID" />
633 <param index="1" name="param" type="int" enum="PhysicsServer2D.BodyParameter" />
634 <param index="2" name="value" type="Variant" />
635 <description>
636 Sets the value of the given body parameter.
637 </description>
638 </method>
639 <method name="body_set_shape">
640 <return type="void" />
641 <param index="0" name="body" type="RID" />
642 <param index="1" name="shape_idx" type="int" />
643 <param index="2" name="shape" type="RID" />
644 <description>
645 Replaces the body's shape at the given index by another shape, while not affecting the [code]transform[/code], [code]disabled[/code], and one-way collision properties at the same index.
646 </description>
647 </method>
648 <method name="body_set_shape_as_one_way_collision">
649 <return type="void" />
650 <param index="0" name="body" type="RID" />
651 <param index="1" name="shape_idx" type="int" />
652 <param index="2" name="enable" type="bool" />
653 <param index="3" name="margin" type="float" />
654 <param index="4" name="direction" type="Vector2" default="Vector2(0, 1)" />
655 <description>
656 Sets the one-way collision properties of the body's shape with the given index. If [param enable] is [code]true[/code], the one-way collision direction given by [param direction] in the shape's local space (that is [code]body_get_shape_transform(body, shape_idx).basis_xform(direction).normalized()[/code] in the body's local space) will be used to ignore collisions with the shape in the opposite direction, and to ensure depenetration of kinematic bodies happens in this direction.
657 </description>
658 </method>
659 <method name="body_set_shape_disabled">
660 <return type="void" />
661 <param index="0" name="body" type="RID" />
662 <param index="1" name="shape_idx" type="int" />
663 <param index="2" name="disabled" type="bool" />
664 <description>
665 Sets the disabled property of the body's shape with the given index. If [param disabled] is [code]true[/code], then the shape will be ignored in all collision detection.
666 </description>
667 </method>
668 <method name="body_set_shape_transform">
669 <return type="void" />
670 <param index="0" name="body" type="RID" />
671 <param index="1" name="shape_idx" type="int" />
672 <param index="2" name="transform" type="Transform2D" />
673 <description>
674 Sets the local transform matrix of the body's shape with the given index.
675 </description>
676 </method>
677 <method name="body_set_space">
678 <return type="void" />
679 <param index="0" name="body" type="RID" />
680 <param index="1" name="space" type="RID" />
681 <description>
682 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 [constant BODY_MODE_RIGID], then adding the body to a space will have the following additional effects:
683 - If the parameter [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.
684 - If the parameter [constant BODY_PARAM_INERTIA] is set to a value [code]&lt;= 0.0[/code], then the value of that parameter will be recalculated based on the body's shapes, mass, and center of mass.
685 [b]Note:[/b] To remove a body from a space without immediately adding it back elsewhere, use [code]PhysicsServer2D.body_set_space(body, RID())[/code].
686 </description>
687 </method>
688 <method name="body_set_state">
689 <return type="void" />
690 <param index="0" name="body" type="RID" />
691 <param index="1" name="state" type="int" enum="PhysicsServer2D.BodyState" />
692 <param index="2" name="value" type="Variant" />
693 <description>
694 Sets the value of a body's state.
695 [b]Note:[/b] The state change doesn't take effect immediately. The state will change on the next physics frame.
696 </description>
697 </method>
698 <method name="body_set_state_sync_callback">
699 <return type="void" />
700 <param index="0" name="body" type="RID" />
701 <param index="1" name="callable" type="Callable" />
702 <description>
703 Sets the body's state synchronization callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()[/code]) to clear the callback.
704 The function [param callable] will be called every physics frame, assuming that the body was active during the previous physics tick, and can be used to fetch the latest state from the physics server.
705 The function [param callable] must take the following parameters:
706 1. [code]state[/code]: a [PhysicsDirectBodyState2D], used to retrieve the body's state.
707 </description>
708 </method>
709 <method name="body_test_motion">
710 <return type="bool" />
711 <param index="0" name="body" type="RID" />
712 <param index="1" name="parameters" type="PhysicsTestMotionParameters2D" />
713 <param index="2" name="result" type="PhysicsTestMotionResult2D" default="null" />
714 <description>
715 Returns [code]true[/code] if a collision would result from moving the body along a motion vector from a given point in space. See [PhysicsTestMotionParameters2D] for the available motion parameters. Optionally a [PhysicsTestMotionResult2D] object can be passed, which will be used to store the information about the resulting collision.
716 </description>
717 </method>
718 <method name="capsule_shape_create">
719 <return type="RID" />
720 <description>
721 Creates a 2D capsule shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the capsule's height and radius.
722 </description>
723 </method>
724 <method name="circle_shape_create">
725 <return type="RID" />
726 <description>
727 Creates a 2D circle shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the circle's radius.
728 </description>
729 </method>
730 <method name="concave_polygon_shape_create">
731 <return type="RID" />
732 <description>
733 Creates a 2D concave polygon shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the concave polygon's segments.
734 </description>
735 </method>
736 <method name="convex_polygon_shape_create">
737 <return type="RID" />
738 <description>
739 Creates a 2D convex polygon shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the convex polygon's points.
740 </description>
741 </method>
742 <method name="damped_spring_joint_get_param" qualifiers="const">
743 <return type="float" />
744 <param index="0" name="joint" type="RID" />
745 <param index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam" />
746 <description>
747 Returns the value of the given damped spring joint parameter.
748 </description>
749 </method>
750 <method name="damped_spring_joint_set_param">
751 <return type="void" />
752 <param index="0" name="joint" type="RID" />
753 <param index="1" name="param" type="int" enum="PhysicsServer2D.DampedSpringParam" />
754 <param index="2" name="value" type="float" />
755 <description>
756 Sets the value of the given damped spring joint parameter.
757 </description>
758 </method>
759 <method name="free_rid">
760 <return type="void" />
761 <param index="0" name="rid" type="RID" />
762 <description>
763 Destroys any of the objects created by PhysicsServer2D. If the [RID] passed is not one of the objects that can be created by PhysicsServer2D, an error will be printed to the console.
764 </description>
765 </method>
766 <method name="get_process_info">
767 <return type="int" />
768 <param index="0" name="process_info" type="int" enum="PhysicsServer2D.ProcessInfo" />
769 <description>
770 Returns the value of a physics engine state specified by [param process_info].
771 </description>
772 </method>
773 <method name="joint_clear">
774 <return type="void" />
775 <param index="0" name="joint" type="RID" />
776 <description>
777 Destroys the joint with the given [RID], creates a new uninitialized joint, and makes the [RID] refer to this new joint.
778 </description>
779 </method>
780 <method name="joint_create">
781 <return type="RID" />
782 <description>
783 Creates a 2D joint in the physics server, and returns the [RID] that identifies it. To set the joint type, use [method joint_make_damped_spring], [method joint_make_groove] or [method joint_make_pin]. Use [method joint_set_param] to set generic joint parameters.
784 </description>
785 </method>
786 <method name="joint_disable_collisions_between_bodies">
787 <return type="void" />
788 <param index="0" name="joint" type="RID" />
789 <param index="1" name="disable" type="bool" />
790 <description>
791 Sets whether the bodies attached to the [Joint2D] will collide with each other.
792 </description>
793 </method>
794 <method name="joint_get_param" qualifiers="const">
795 <return type="float" />
796 <param index="0" name="joint" type="RID" />
797 <param index="1" name="param" type="int" enum="PhysicsServer2D.JointParam" />
798 <description>
799 Returns the value of the given joint parameter.
800 </description>
801 </method>
802 <method name="joint_get_type" qualifiers="const">
803 <return type="int" enum="PhysicsServer2D.JointType" />
804 <param index="0" name="joint" type="RID" />
805 <description>
806 Returns the joint's type.
807 </description>
808 </method>
809 <method name="joint_is_disabled_collisions_between_bodies" qualifiers="const">
810 <return type="bool" />
811 <param index="0" name="joint" type="RID" />
812 <description>
813 Returns whether the bodies attached to the [Joint2D] will collide with each other.
814 </description>
815 </method>
816 <method name="joint_make_damped_spring">
817 <return type="void" />
818 <param index="0" name="joint" type="RID" />
819 <param index="1" name="anchor_a" type="Vector2" />
820 <param index="2" name="anchor_b" type="Vector2" />
821 <param index="3" name="body_a" type="RID" />
822 <param index="4" name="body_b" type="RID" default="RID()" />
823 <description>
824 Makes the joint a damped spring joint, attached at the point [param anchor_a] (given in global coordinates) on the body [param body_a] and at the point [param anchor_b] (given in global coordinates) on the body [param body_b]. To set the parameters which are specific to the damped spring, see [method damped_spring_joint_set_param].
825 </description>
826 </method>
827 <method name="joint_make_groove">
828 <return type="void" />
829 <param index="0" name="joint" type="RID" />
830 <param index="1" name="groove1_a" type="Vector2" />
831 <param index="2" name="groove2_a" type="Vector2" />
832 <param index="3" name="anchor_b" type="Vector2" />
833 <param index="4" name="body_a" type="RID" default="RID()" />
834 <param index="5" name="body_b" type="RID" default="RID()" />
835 <description>
836 Makes the joint a groove joint.
837 </description>
838 </method>
839 <method name="joint_make_pin">
840 <return type="void" />
841 <param index="0" name="joint" type="RID" />
842 <param index="1" name="anchor" type="Vector2" />
843 <param index="2" name="body_a" type="RID" />
844 <param index="3" name="body_b" type="RID" default="RID()" />
845 <description>
846 Makes the joint a pin joint. If [param body_b] is an empty [RID], then [param body_a] is pinned to the point [param anchor] (given in global coordinates); otherwise, [param body_a] is pinned to [param body_b] at the point [param anchor] (given in global coordinates). To set the parameters which are specific to the pin joint, see [method pin_joint_set_param].
847 </description>
848 </method>
849 <method name="joint_set_param">
850 <return type="void" />
851 <param index="0" name="joint" type="RID" />
852 <param index="1" name="param" type="int" enum="PhysicsServer2D.JointParam" />
853 <param index="2" name="value" type="float" />
854 <description>
855 Sets the value of the given joint parameter.
856 </description>
857 </method>
858 <method name="pin_joint_get_flag" qualifiers="const">
859 <return type="bool" />
860 <param index="0" name="joint" type="RID" />
861 <param index="1" name="flag" type="int" enum="PhysicsServer2D.PinJointFlag" />
862 <description>
863 Gets a pin joint flag.
864 </description>
865 </method>
866 <method name="pin_joint_get_param" qualifiers="const">
867 <return type="float" />
868 <param index="0" name="joint" type="RID" />
869 <param index="1" name="param" type="int" enum="PhysicsServer2D.PinJointParam" />
870 <description>
871 Returns the value of a pin joint parameter.
872 </description>
873 </method>
874 <method name="pin_joint_set_flag">
875 <return type="void" />
876 <param index="0" name="joint" type="RID" />
877 <param index="1" name="flag" type="int" enum="PhysicsServer2D.PinJointFlag" />
878 <param index="2" name="enabled" type="bool" />
879 <description>
880 Sets a pin joint flag.
881 </description>
882 </method>
883 <method name="pin_joint_set_param">
884 <return type="void" />
885 <param index="0" name="joint" type="RID" />
886 <param index="1" name="param" type="int" enum="PhysicsServer2D.PinJointParam" />
887 <param index="2" name="value" type="float" />
888 <description>
889 Sets a pin joint parameter.
890 </description>
891 </method>
892 <method name="rectangle_shape_create">
893 <return type="RID" />
894 <description>
895 Creates a 2D rectangle shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the rectangle's half-extents.
896 </description>
897 </method>
898 <method name="segment_shape_create">
899 <return type="RID" />
900 <description>
901 Creates a 2D segment shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the segment's start and end points.
902 </description>
903 </method>
904 <method name="separation_ray_shape_create">
905 <return type="RID" />
906 <description>
907 Creates a 2D separation ray shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the shape's [code]length[/code] and [code]slide_on_slope[/code] properties.
908 </description>
909 </method>
910 <method name="set_active">
911 <return type="void" />
912 <param index="0" name="active" type="bool" />
913 <description>
914 Activates or deactivates the 2D physics server. If [param active] is [code]false[/code], then the physics server will not do anything in its physics step.
915 </description>
916 </method>
917 <method name="shape_get_data" qualifiers="const">
918 <return type="Variant" />
919 <param index="0" name="shape" type="RID" />
920 <description>
921 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 [method shape_set_data] for the precise format of this data in each case.
922 </description>
923 </method>
924 <method name="shape_get_type" qualifiers="const">
925 <return type="int" enum="PhysicsServer2D.ShapeType" />
926 <param index="0" name="shape" type="RID" />
927 <description>
928 Returns the shape's type.
929 </description>
930 </method>
931 <method name="shape_set_data">
932 <return type="void" />
933 <param index="0" name="shape" type="RID" />
934 <param index="1" name="data" type="Variant" />
935 <description>
936 Sets the shape data that defines the configuration of the shape. The [param data] to be passed depends on the shape's type (see [method shape_get_type]):
937 - [constant SHAPE_WORLD_BOUNDARY]: an array of length two containing a [Vector2] [code]normal[/code] direction and a [float] distance [code]d[/code],
938 - [constant SHAPE_SEPARATION_RAY]: a dictionary containing the key [code]length[/code] with a [float] value and the key [code]slide_on_slope[/code] with a [bool] value,
939 - [constant SHAPE_SEGMENT]: a [Rect2] [code]rect[/code] containing the first point of the segment in [code]rect.position[/code] and the second point of the segment in [code]rect.size[/code],
940 - [constant SHAPE_CIRCLE]: a [float] [code]radius[/code],
941 - [constant SHAPE_RECTANGLE]: a [Vector2] [code]half_extents[/code],
942 - [constant SHAPE_CAPSULE]: an array of length two (or a [Vector2]) containing a [float] [code]height[/code] and a [float] [code]radius[/code],
943 - [constant SHAPE_CONVEX_POLYGON]: either a [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 [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,
944 - [constant SHAPE_CONCAVE_POLYGON]: a [PackedVector2Array] of length divisible by two (each pair of points forms one segment).
945 [b]Warning:[/b] In the case of [constant SHAPE_CONVEX_POLYGON], this method does not check if the points supplied actually form a convex polygon (unlike the [member CollisionPolygon2D.polygon] property).
946 </description>
947 </method>
948 <method name="space_create">
949 <return type="RID" />
950 <description>
951 Creates a 2D space in the physics server, and returns the [RID] that identifies it. A space contains bodies and areas, and controls the stepping of the physics simulation of the objects in it.
952 </description>
953 </method>
954 <method name="space_get_direct_state">
955 <return type="PhysicsDirectSpaceState2D" />
956 <param index="0" name="space" type="RID" />
957 <description>
958 Returns the state of a space, a [PhysicsDirectSpaceState2D]. This object can be used for collision/intersection queries.
959 </description>
960 </method>
961 <method name="space_get_param" qualifiers="const">
962 <return type="float" />
963 <param index="0" name="space" type="RID" />
964 <param index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter" />
965 <description>
966 Returns the value of the given space parameter.
967 </description>
968 </method>
969 <method name="space_is_active" qualifiers="const">
970 <return type="bool" />
971 <param index="0" name="space" type="RID" />
972 <description>
973 Returns [code]true[/code] if the space is active.
974 </description>
975 </method>
976 <method name="space_set_active">
977 <return type="void" />
978 <param index="0" name="space" type="RID" />
979 <param index="1" name="active" type="bool" />
980 <description>
981 Activates or deactivates the space. If [param active] is [code]false[/code], then the physics server will not do anything with this space in its physics step.
982 </description>
983 </method>
984 <method name="space_set_param">
985 <return type="void" />
986 <param index="0" name="space" type="RID" />
987 <param index="1" name="param" type="int" enum="PhysicsServer2D.SpaceParameter" />
988 <param index="2" name="value" type="float" />
989 <description>
990 Sets the value of the given space parameter.
991 </description>
992 </method>
993 <method name="world_boundary_shape_create">
994 <return type="RID" />
995 <description>
996 Creates a 2D world boundary shape in the physics server, and returns the [RID] that identifies it. Use [method shape_set_data] to set the shape's normal direction and distance properties.
997 </description>
998 </method>
999 </methods>
1000 <constants>
1001 <constant name="SPACE_PARAM_CONTACT_RECYCLE_RADIUS" value="0" enum="SpaceParameter">
1002 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 [member ProjectSettings.physics/2d/solver/contact_recycle_radius].
1003 </constant>
1004 <constant name="SPACE_PARAM_CONTACT_MAX_SEPARATION" value="1" enum="SpaceParameter">
1005 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 [member ProjectSettings.physics/2d/solver/contact_max_separation].
1006 </constant>
1007 <constant name="SPACE_PARAM_CONTACT_MAX_ALLOWED_PENETRATION" value="2" enum="SpaceParameter">
1008 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 [member ProjectSettings.physics/2d/solver/contact_max_allowed_penetration].
1009 </constant>
1010 <constant name="SPACE_PARAM_CONTACT_DEFAULT_BIAS" value="3" enum="SpaceParameter">
1011 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 [member ProjectSettings.physics/2d/solver/default_contact_bias].
1012 </constant>
1013 <constant name="SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD" value="4" enum="SpaceParameter">
1014 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 [member ProjectSettings.physics/2d/sleep_threshold_linear].
1015 </constant>
1016 <constant name="SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD" value="5" enum="SpaceParameter">
1017 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 [member ProjectSettings.physics/2d/sleep_threshold_angular].
1018 </constant>
1019 <constant name="SPACE_PARAM_BODY_TIME_TO_SLEEP" value="6" enum="SpaceParameter">
1020 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 [member ProjectSettings.physics/2d/time_before_sleep].
1021 </constant>
1022 <constant name="SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS" value="7" enum="SpaceParameter">
1023 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 [member ProjectSettings.physics/2d/solver/default_constraint_bias].
1024 </constant>
1025 <constant name="SPACE_PARAM_SOLVER_ITERATIONS" value="8" enum="SpaceParameter">
1026 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 [member ProjectSettings.physics/2d/solver/solver_iterations].
1027 </constant>
1028 <constant name="SHAPE_WORLD_BOUNDARY" value="0" enum="ShapeType">
1029 This is the constant for creating world boundary shapes. A world boundary shape is an [i]infinite[/i] line with an origin point, and a normal. Thus, it can be used for front/behind checks.
1030 </constant>
1031 <constant name="SHAPE_SEPARATION_RAY" value="1" enum="ShapeType">
1032 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.
1033 </constant>
1034 <constant name="SHAPE_SEGMENT" value="2" enum="ShapeType">
1035 This is the constant for creating segment shapes. A segment shape is a [i]finite[/i] line from a point A to a point B. It can be checked for intersections.
1036 </constant>
1037 <constant name="SHAPE_CIRCLE" value="3" enum="ShapeType">
1038 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.
1039 </constant>
1040 <constant name="SHAPE_RECTANGLE" value="4" enum="ShapeType">
1041 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.
1042 </constant>
1043 <constant name="SHAPE_CAPSULE" value="5" enum="ShapeType">
1044 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.
1045 </constant>
1046 <constant name="SHAPE_CONVEX_POLYGON" value="6" enum="ShapeType">
1047 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.
1048 </constant>
1049 <constant name="SHAPE_CONCAVE_POLYGON" value="7" enum="ShapeType">
1050 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.
1051 </constant>
1052 <constant name="SHAPE_CUSTOM" value="8" enum="ShapeType">
1053 This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
1054 </constant>
1055 <constant name="AREA_PARAM_GRAVITY_OVERRIDE_MODE" value="0" enum="AreaParameter">
1056 Constant to set/get gravity override mode in an area. See [enum AreaSpaceOverrideMode] for possible values. The default value of this parameter is [constant AREA_SPACE_OVERRIDE_DISABLED].
1057 </constant>
1058 <constant name="AREA_PARAM_GRAVITY" value="1" enum="AreaParameter">
1059 Constant to set/get gravity strength in an area. The default value of this parameter is [code]9.80665[/code].
1060 </constant>
1061 <constant name="AREA_PARAM_GRAVITY_VECTOR" value="2" enum="AreaParameter">
1062 Constant to set/get gravity vector/center in an area. The default value of this parameter is [code]Vector2(0, -1)[/code].
1063 </constant>
1064 <constant name="AREA_PARAM_GRAVITY_IS_POINT" value="3" enum="AreaParameter">
1065 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 [code]false[/code].
1066 </constant>
1067 <constant name="AREA_PARAM_GRAVITY_POINT_UNIT_DISTANCE" value="4" enum="AreaParameter">
1068 Constant to set/get the distance at which the gravity strength is equal to the gravity controlled by [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, 4× the gravity), and so on.
1069 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 [code]0.0[/code].
1070 </constant>
1071 <constant name="AREA_PARAM_LINEAR_DAMP_OVERRIDE_MODE" value="5" enum="AreaParameter">
1072 Constant to set/get linear damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values. The default value of this parameter is [constant AREA_SPACE_OVERRIDE_DISABLED].
1073 </constant>
1074 <constant name="AREA_PARAM_LINEAR_DAMP" value="6" enum="AreaParameter">
1075 Constant to set/get the linear damping factor of an area. The default value of this parameter is [code]0.1[/code].
1076 </constant>
1077 <constant name="AREA_PARAM_ANGULAR_DAMP_OVERRIDE_MODE" value="7" enum="AreaParameter">
1078 Constant to set/get angular damping override mode in an area. See [enum AreaSpaceOverrideMode] for possible values. The default value of this parameter is [constant AREA_SPACE_OVERRIDE_DISABLED].
1079 </constant>
1080 <constant name="AREA_PARAM_ANGULAR_DAMP" value="8" enum="AreaParameter">
1081 Constant to set/get the angular damping factor of an area. The default value of this parameter is [code]1.0[/code].
1082 </constant>
1083 <constant name="AREA_PARAM_PRIORITY" value="9" enum="AreaParameter">
1084 Constant to set/get the priority (order of processing) of an area. The default value of this parameter is [code]0[/code].
1085 </constant>
1086 <constant name="AREA_SPACE_OVERRIDE_DISABLED" value="0" enum="AreaSpaceOverrideMode">
1087 This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
1088 </constant>
1089 <constant name="AREA_SPACE_OVERRIDE_COMBINE" value="1" enum="AreaSpaceOverrideMode">
1090 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.
1091 </constant>
1092 <constant name="AREA_SPACE_OVERRIDE_COMBINE_REPLACE" value="2" enum="AreaSpaceOverrideMode">
1093 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.
1094 </constant>
1095 <constant name="AREA_SPACE_OVERRIDE_REPLACE" value="3" enum="AreaSpaceOverrideMode">
1096 This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
1097 </constant>
1098 <constant name="AREA_SPACE_OVERRIDE_REPLACE_COMBINE" value="4" enum="AreaSpaceOverrideMode">
1099 This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
1100 </constant>
1101 <constant name="BODY_MODE_STATIC" value="0" enum="BodyMode">
1102 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.
1103 </constant>
1104 <constant name="BODY_MODE_KINEMATIC" value="1" enum="BodyMode">
1105 Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path.
1106 </constant>
1107 <constant name="BODY_MODE_RIGID" value="2" enum="BodyMode">
1108 Constant for rigid bodies. In this mode, a body can be pushed by other bodies and has forces applied.
1109 </constant>
1110 <constant name="BODY_MODE_RIGID_LINEAR" value="3" enum="BodyMode">
1111 Constant for linear rigid bodies. In this mode, a body can not rotate, and only its linear velocity is affected by external forces.
1112 </constant>
1113 <constant name="BODY_PARAM_BOUNCE" value="0" enum="BodyParameter">
1114 Constant to set/get a body's bounce factor. The default value of this parameter is [code]0.0[/code].
1115 </constant>
1116 <constant name="BODY_PARAM_FRICTION" value="1" enum="BodyParameter">
1117 Constant to set/get a body's friction. The default value of this parameter is [code]1.0[/code].
1118 </constant>
1119 <constant name="BODY_PARAM_MASS" value="2" enum="BodyParameter">
1120 Constant to set/get a body's mass. The default value of this parameter is [code]1.0[/code]. If the body's mode is set to [constant BODY_MODE_RIGID], then setting this parameter will have the following additional effects:
1121 - If the parameter [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.
1122 - If the parameter [constant BODY_PARAM_INERTIA] is set to a value [code]&lt;= 0.0[/code], then the value of that parameter will be recalculated based on the body's shapes, mass, and center of mass.
1123 </constant>
1124 <constant name="BODY_PARAM_INERTIA" value="3" enum="BodyParameter">
1125 Constant to set/get a body's inertia. The default value of this parameter is [code]0.0[/code]. If the body's inertia is set to a value [code]&lt;= 0.0[/code], then the inertia will be recalculated based on the body's shapes, mass, and center of mass.
1126 </constant>
1127 <constant name="BODY_PARAM_CENTER_OF_MASS" value="4" enum="BodyParameter">
1128 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 [code]Vector2(0, 0)[/code]. If this parameter is never set explicitly, then it is recalculated based on the body's shapes when setting the parameter [constant BODY_PARAM_MASS] or when calling [method body_set_space].
1129 </constant>
1130 <constant name="BODY_PARAM_GRAVITY_SCALE" value="5" enum="BodyParameter">
1131 Constant to set/get a body's gravity multiplier. The default value of this parameter is [code]1.0[/code].
1132 </constant>
1133 <constant name="BODY_PARAM_LINEAR_DAMP_MODE" value="6" enum="BodyParameter">
1134 Constant to set/get a body's linear damping mode. See [enum BodyDampMode] for possible values. The default value of this parameter is [constant BODY_DAMP_MODE_COMBINE].
1135 </constant>
1136 <constant name="BODY_PARAM_ANGULAR_DAMP_MODE" value="7" enum="BodyParameter">
1137 Constant to set/get a body's angular damping mode. See [enum BodyDampMode] for possible values. The default value of this parameter is [constant BODY_DAMP_MODE_COMBINE].
1138 </constant>
1139 <constant name="BODY_PARAM_LINEAR_DAMP" value="8" enum="BodyParameter">
1140 Constant to set/get a body's linear damping factor. The default value of this parameter is [code]0.0[/code].
1141 </constant>
1142 <constant name="BODY_PARAM_ANGULAR_DAMP" value="9" enum="BodyParameter">
1143 Constant to set/get a body's angular damping factor. The default value of this parameter is [code]0.0[/code].
1144 </constant>
1145 <constant name="BODY_PARAM_MAX" value="10" enum="BodyParameter">
1146 Represents the size of the [enum BodyParameter] enum.
1147 </constant>
1148 <constant name="BODY_DAMP_MODE_COMBINE" value="0" enum="BodyDampMode">
1149 The body's damping value is added to any value set in areas or the default value.
1150 </constant>
1151 <constant name="BODY_DAMP_MODE_REPLACE" value="1" enum="BodyDampMode">
1152 The body's damping value replaces any value set in areas or the default value.
1153 </constant>
1154 <constant name="BODY_STATE_TRANSFORM" value="0" enum="BodyState">
1155 Constant to set/get the current transform matrix of the body.
1156 </constant>
1157 <constant name="BODY_STATE_LINEAR_VELOCITY" value="1" enum="BodyState">
1158 Constant to set/get the current linear velocity of the body.
1159 </constant>
1160 <constant name="BODY_STATE_ANGULAR_VELOCITY" value="2" enum="BodyState">
1161 Constant to set/get the current angular velocity of the body.
1162 </constant>
1163 <constant name="BODY_STATE_SLEEPING" value="3" enum="BodyState">
1164 Constant to sleep/wake up a body, or to get whether it is sleeping.
1165 </constant>
1166 <constant name="BODY_STATE_CAN_SLEEP" value="4" enum="BodyState">
1167 Constant to set/get whether the body can sleep.
1168 </constant>
1169 <constant name="JOINT_TYPE_PIN" value="0" enum="JointType">
1170 Constant to create pin joints.
1171 </constant>
1172 <constant name="JOINT_TYPE_GROOVE" value="1" enum="JointType">
1173 Constant to create groove joints.
1174 </constant>
1175 <constant name="JOINT_TYPE_DAMPED_SPRING" value="2" enum="JointType">
1176 Constant to create damped spring joints.
1177 </constant>
1178 <constant name="JOINT_TYPE_MAX" value="3" enum="JointType">
1179 Represents the size of the [enum JointType] enum.
1180 </constant>
1181 <constant name="JOINT_PARAM_BIAS" value="0" enum="JointParam">
1182 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 [code]0.0[/code].
1183 [b]Note:[/b] In Godot Physics, this parameter is only used for pin joints and groove joints.
1184 </constant>
1185 <constant name="JOINT_PARAM_MAX_BIAS" value="1" enum="JointParam">
1186 Constant to set/get the maximum speed with which the joint can apply corrections. The default value of this parameter is [code]3.40282e+38[/code].
1187 [b]Note:[/b] In Godot Physics, this parameter is only used for groove joints.
1188 </constant>
1189 <constant name="JOINT_PARAM_MAX_FORCE" value="2" enum="JointParam">
1190 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 [code]3.40282e+38[/code].
1191 [b]Note:[/b] In Godot Physics, this parameter is only used for groove joints.
1192 </constant>
1193 <constant name="PIN_JOINT_SOFTNESS" value="0" enum="PinJointParam">
1194 Constant to set/get a how much the bond of the pin joint can flex. The default value of this parameter is [code]0.0[/code].
1195 </constant>
1196 <constant name="PIN_JOINT_LIMIT_UPPER" value="1" enum="PinJointParam">
1197 The maximum rotation around the pin.
1198 </constant>
1199 <constant name="PIN_JOINT_LIMIT_LOWER" value="2" enum="PinJointParam">
1200 The minimum rotation around the pin.
1201 </constant>
1202 <constant name="PIN_JOINT_MOTOR_TARGET_VELOCITY" value="3" enum="PinJointParam">
1203 Target speed for the motor. In radians per second.
1204 </constant>
1205 <constant name="PIN_JOINT_FLAG_ANGULAR_LIMIT_ENABLED" value="0" enum="PinJointFlag">
1206 If [code]true[/code], the pin has a maximum and a minimum rotation.
1207 </constant>
1208 <constant name="PIN_JOINT_FLAG_MOTOR_ENABLED" value="1" enum="PinJointFlag">
1209 If [code]true[/code], a motor turns the pin.
1210 </constant>
1211 <constant name="DAMPED_SPRING_REST_LENGTH" value="0" enum="DampedSpringParam">
1212 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.
1213 </constant>
1214 <constant name="DAMPED_SPRING_STIFFNESS" value="1" enum="DampedSpringParam">
1215 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 [code]20.0[/code].
1216 </constant>
1217 <constant name="DAMPED_SPRING_DAMPING" value="2" enum="DampedSpringParam">
1218 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 [code]1.5[/code].
1219 </constant>
1220 <constant name="CCD_MODE_DISABLED" value="0" enum="CCDMode">
1221 Disables continuous collision detection. This is the fastest way to detect body collisions, but it can miss small and/or fast-moving objects.
1222 </constant>
1223 <constant name="CCD_MODE_CAST_RAY" value="1" enum="CCDMode">
1224 Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise.
1225 </constant>
1226 <constant name="CCD_MODE_CAST_SHAPE" value="2" enum="CCDMode">
1227 Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise.
1228 </constant>
1229 <constant name="AREA_BODY_ADDED" value="0" enum="AreaBodyStatus">
1230 The value of the first parameter and area callback function receives, when an object enters one of its shapes.
1231 </constant>
1232 <constant name="AREA_BODY_REMOVED" value="1" enum="AreaBodyStatus">
1233 The value of the first parameter and area callback function receives, when an object exits one of its shapes.
1234 </constant>
1235 <constant name="INFO_ACTIVE_OBJECTS" value="0" enum="ProcessInfo">
1236 Constant to get the number of objects that are not sleeping.
1237 </constant>
1238 <constant name="INFO_COLLISION_PAIRS" value="1" enum="ProcessInfo">
1239 Constant to get the number of possible collisions.
1240 </constant>
1241 <constant name="INFO_ISLAND_COUNT" value="2" enum="ProcessInfo">
1242 Constant to get the number of space regions where a collision could occur.
1243 </constant>
1244 </constants>
1245</class>