PhysicsServer2D
A server interface for low-level 2D physics access.
A server interface for low-level 2D physics access.
PhysicsServer2D is the server responsible for all 2D physics. It can directly create and manipulate all physics objects:
- 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.
- 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.
- 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.
- 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.
- 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.
Physics objects in
PhysicsServer2Dmay be created and manipulated independently; they do not have to be tied to nodes in the scene tree. 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.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties1
SingletonProperty
public static PhysicsServer2DInstance Singleton { get; }Methods120
AreaAddShapevoid
public static void AreaAddShape(Rid area, Rid shape, Transform2D? transform = default, bool disabled = false);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.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
shape | Rid | — |
transform | Transform2D? | default |
disabled | bool | false |
transformIf the parameter is null, then the default value is Transform2D.Identity.
AreaAttachCanvasInstanceIdvoid
public static void AreaAttachCanvasInstanceId(Rid area, ulong id);Attaches the ObjectID of a canvas to the area. Use ReckfellObject.GetInstanceId to get the ObjectID of a CanvasLayer.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
id | ulong | — |
AreaAttachObjectInstanceIdvoid
public static void AreaAttachObjectInstanceId(Rid area, ulong id);Attaches the ObjectID of an ReckfellObject to the area. Use ReckfellObject.GetInstanceId to get the ObjectID of a CollisionObject2D.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
id | ulong | — |
AreaClearShapesvoid
public static void AreaClearShapes(Rid area);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.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
AreaCreateRid
public static Rid AreaCreate();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 1, and monitorable set to false.
Use PhysicsServer2D.AreaAddShape to add shapes to it, use PhysicsServer2D.AreaSetTransform to set its transform, and use PhysicsServer2D.AreaSetSpace to add the area to a space. If you want the area to be detectable use PhysicsServer2D.AreaSetMonitorable.
RidAreaGetCanvasInstanceIdulong
public static ulong AreaGetCanvasInstanceId(Rid area);Returns the ObjectID of the canvas attached to the area. Use @GlobalScope.instance_from_id to retrieve a CanvasLayer from a nonzero ObjectID.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
ulongAreaGetCollisionLayeruint
public static uint AreaGetCollisionLayer(Rid area);Returns the physics layer or layers the area belongs to, as a bitmask.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
uintAreaGetCollisionMaskuint
public static uint AreaGetCollisionMask(Rid area);Returns the physics layer or layers the area can contact with, as a bitmask.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
uintAreaGetObjectInstanceIdulong
public static ulong AreaGetObjectInstanceId(Rid area);Returns the ObjectID attached to the area. Use @GlobalScope.instance_from_id to retrieve an ReckfellObject from a nonzero ObjectID.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
ulongAreaGetParamVariant
public static Variant AreaGetParam(Rid area, PhysicsServer2D.AreaParameter param);Returns the value of the given area parameter.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
param | PhysicsServer2D.AreaParameter | — |
VariantAreaGetShapeRid
public static Rid AreaGetShape(Rid area, int shapeIdx);Returns the Rid of the shape with the given index in the area's array of shapes.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
shapeIdx | int | — |
RidAreaGetShapeCountint
public static int AreaGetShapeCount(Rid area);Returns the number of shapes added to the area.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
intAreaGetShapeTransformTransform2D
public static Transform2D AreaGetShapeTransform(Rid area, int shapeIdx);Returns the local transform matrix of the shape with the given index in the area's array of shapes.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
shapeIdx | int | — |
Transform2DAreaGetSpaceRid
public static Rid AreaGetSpace(Rid area);Returns the Rid of the space assigned to the area. Returns an empty Rid if no space is assigned.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
RidAreaGetTransformTransform2D
public static Transform2D AreaGetTransform(Rid area);Returns the transform matrix of the area.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
Transform2DAreaRemoveShapevoid
public static void AreaRemoveShape(Rid area, int shapeIdx);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.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
shapeIdx | int | — |
AreaSetAreaMonitorCallbackvoid
public static void AreaSetAreaMonitorCallback(Rid area, Callable callback);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:
- an integer
status: eitherPhysicsServer2D.AreaBodyStatus.AddedorPhysicsServer2D.AreaBodyStatus.Removeddepending on whether the other area's shape entered or exited the area, - an
Ridarea_rid: theRidof the other area that entered or exited the area, - an integer
instance_id: theObjectIDattached to the other area, - an integer
area_shape_idx: the index of the shape of the other area that entered or exited the area, - an integer
self_shape_idx: the index of the shape of the area where the other area entered or exited. 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.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
callback | Callable | — |
AreaSetCollisionLayervoid
public static void AreaSetCollisionLayer(Rid area, uint layer);Assigns the area to one or many physics layers, via a bitmask.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
layer | uint | — |
AreaSetCollisionMaskvoid
public static void AreaSetCollisionMask(Rid area, uint mask);Sets which physics layers the area will monitor, via a bitmask.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
mask | uint | — |
AreaSetMonitorCallbackvoid
public static void AreaSetMonitorCallback(Rid area, Callable callback);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:
- an integer
status: eitherPhysicsServer2D.AreaBodyStatus.AddedorPhysicsServer2D.AreaBodyStatus.Removeddepending on whether the other body shape entered or exited the area, - an
Ridbody_rid: theRidof the body that entered or exited the area, - an integer
instance_id: theObjectIDattached to the body, - an integer
body_shape_idx: the index of the shape of the body that entered or exited the area, - an integer
self_shape_idx: the index of the shape of the area where the body entered or exited. 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.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
callback | Callable | — |
AreaSetMonitorablevoid
public static void AreaSetMonitorable(Rid area, bool monitorable);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.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
monitorable | bool | — |
AreaSetParamvoid
public static void AreaSetParam(Rid area, PhysicsServer2D.AreaParameter param, Variant value);Sets the value of the given area parameter.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
param | PhysicsServer2D.AreaParameter | — |
value | Variant | — |
AreaSetShapevoid
public static void AreaSetShape(Rid area, int shapeIdx, Rid shape);Replaces the area's shape at the given index by another shape, while not affecting the transform and disabled properties at the same index.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
shapeIdx | int | — |
shape | Rid | — |
AreaSetShapeDisabledvoid
public static void AreaSetShapeDisabled(Rid area, int shapeIdx, bool disabled);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.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
shapeIdx | int | — |
disabled | bool | — |
AreaSetShapeTransformvoid
public static void AreaSetShapeTransform(Rid area, int shapeIdx, Transform2D transform);Sets the local transform matrix of the area's shape with the given index.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
shapeIdx | int | — |
transform | Transform2D | — |
AreaSetSpacevoid
public static void AreaSetSpace(Rid area, Rid space);Adds the area to the given space, after removing the area from the previously assigned space (if any).
Note: To remove an area from a space without immediately adding it back elsewhere, use PhysicsServer2D.area_set_space(area, RID()).
| Name | Type | Default |
|---|---|---|
area | Rid | — |
space | Rid | — |
AreaSetTransformvoid
public static void AreaSetTransform(Rid area, Transform2D transform);Sets the transform matrix of the area.
| Name | Type | Default |
|---|---|---|
area | Rid | — |
transform | Transform2D | — |
BodyAddCollisionExceptionvoid
public static void BodyAddCollisionException(Rid body, Rid exceptedBody);Adds excepted_body to the body's list of collision exceptions, so that collisions with it are ignored.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
exceptedBody | Rid | — |
BodyAddConstantCentralForcevoid
public static void BodyAddConstantCentralForce(Rid body, Vector2 force);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)).
This is equivalent to using PhysicsServer2D.BodyAddConstantForce at the body's center of mass.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
force | Vector2 | — |
BodyAddConstantForcevoid
public static void BodyAddConstantForce(Rid body, Vector2 force, Vector2? position = default);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)).
position is the offset from the body origin in global coordinates.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
force | Vector2 | — |
position | Vector2? | default |
positionIf the parameter is null, then the default value is new Vector2(0.0f, 0.0f).
BodyAddConstantTorquevoid
public static void BodyAddConstantTorque(Rid body, float torque);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).
| Name | Type | Default |
|---|---|---|
body | Rid | — |
torque | float | — |
BodyAddShapevoid
public static void BodyAddShape(Rid body, Rid shape, Transform2D? transform = default, bool disabled = false);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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
shape | Rid | — |
transform | Transform2D? | default |
disabled | bool | false |
transformIf the parameter is null, then the default value is Transform2D.Identity.
BodyApplyCentralForcevoid
public static void BodyApplyCentralForce(Rid body, Vector2 force);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.
This is equivalent to using PhysicsServer2D.BodyApplyForce at the body's center of mass.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
force | Vector2 | — |
BodyApplyCentralImpulsevoid
public static void BodyApplyCentralImpulse(Rid body, Vector2 impulse);Applies a directional impulse to the body, at the body's center of mass. The impulse does not affect rotation.
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).
This is equivalent to using PhysicsServer2D.BodyApplyImpulse at the body's center of mass.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
impulse | Vector2 | — |
BodyApplyForcevoid
public static void BodyApplyForce(Rid body, Vector2 force, Vector2? position = default);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.
position is the offset from the body origin in global coordinates.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
force | Vector2 | — |
position | Vector2? | default |
positionIf the parameter is null, then the default value is new Vector2(0.0f, 0.0f).
BodyApplyImpulsevoid
public static void BodyApplyImpulse(Rid body, Vector2 impulse, Vector2? position = default);Applies a positioned impulse to the body. The impulse can affect rotation if position is different from the body's center of mass.
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).
position is the offset from the body origin in global coordinates.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
impulse | Vector2 | — |
position | Vector2? | default |
positionIf the parameter is null, then the default value is new Vector2(0.0f, 0.0f).
BodyApplyTorquevoid
public static void BodyApplyTorque(Rid body, float torque);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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
torque | float | — |
BodyApplyTorqueImpulsevoid
public static void BodyApplyTorqueImpulse(Rid body, float impulse);Applies a rotational impulse to the body. The impulse does not affect position. 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).
| Name | Type | Default |
|---|---|---|
body | Rid | — |
impulse | float | — |
BodyAttachCanvasInstanceIdvoid
public static void BodyAttachCanvasInstanceId(Rid body, ulong id);Attaches the ObjectID of a canvas to the body. Use ReckfellObject.GetInstanceId to get the ObjectID of a CanvasLayer.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
id | ulong | — |
BodyAttachObjectInstanceIdvoid
public static void BodyAttachObjectInstanceId(Rid body, ulong id);Attaches the ObjectID of an ReckfellObject to the body. Use ReckfellObject.GetInstanceId to get the ObjectID of a CollisionObject2D.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
id | ulong | — |
BodyClearShapesvoid
public static void BodyClearShapes(Rid body);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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
BodyCreateRid
public static Rid BodyCreate();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 1, and body mode set to PhysicsServer2D.BodyMode.Rigid.
Use PhysicsServer2D.BodyAddShape to add shapes to it, use PhysicsServer2D.BodySetState to set its transform, and use PhysicsServer2D.BodySetSpace to add the body to a space.
RidBodyGetCanvasInstanceIdulong
public static ulong BodyGetCanvasInstanceId(Rid body);Returns the ObjectID of the canvas attached to the body. Use @GlobalScope.instance_from_id to retrieve a CanvasLayer from a nonzero ObjectID.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
ulongBodyGetCollisionLayeruint
public static uint BodyGetCollisionLayer(Rid body);Returns the physics layer or layers the body belongs to, as a bitmask.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
uintBodyGetCollisionMaskuint
public static uint BodyGetCollisionMask(Rid body);Returns the physics layer or layers the body can collide with, as a bitmask.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
uintBodyGetCollisionPriorityfloat
public static float BodyGetCollisionPriority(Rid body);Returns the body's collision priority. This is used in the depenetration phase of PhysicsServer2D.BodyTestMotion. The higher the priority is, the lower the penetration into the body will be.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
floatBodyGetConstantForceVector2
public static Vector2 BodyGetConstantForce(Rid body);Returns the body's total constant positional force applied during each physics update.
See PhysicsServer2D.BodyAddConstantForce and PhysicsServer2D.BodyAddConstantCentralForce.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
Vector2BodyGetConstantTorquefloat
public static float BodyGetConstantTorque(Rid body);Returns the body's total constant rotational force applied during each physics update.
See PhysicsServer2D.BodyAddConstantTorque.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
floatBodyGetContinuousCollisionDetectionModePhysicsServer2D.CcdMode
public static PhysicsServer2D.CcdMode BodyGetContinuousCollisionDetectionMode(Rid body);Returns the body's continuous collision detection mode.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
PhysicsServer2D.CcdModeBodyGetDirectStatePhysicsDirectBodyState2D
public static PhysicsDirectBodyState2D BodyGetDirectState(Rid body);Returns the PhysicsDirectBodyState2D of the body. Returns null if the body is destroyed or not assigned to a space.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
PhysicsDirectBodyState2DBodyGetMaxContactsReportedint
public static int BodyGetMaxContactsReported(Rid body);Returns the maximum number of contacts that the body can report. See PhysicsServer2D.BodySetMaxContactsReported.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
intBodyGetModePhysicsServer2D.BodyMode
public static PhysicsServer2D.BodyMode BodyGetMode(Rid body);Returns the body's mode.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
PhysicsServer2D.BodyModeBodyGetObjectInstanceIdulong
public static ulong BodyGetObjectInstanceId(Rid body);Returns the ObjectID attached to the body. Use @GlobalScope.instance_from_id to retrieve an ReckfellObject from a nonzero ObjectID.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
ulongBodyGetParamVariant
public static Variant BodyGetParam(Rid body, PhysicsServer2D.BodyParameter param);Returns the value of the given body parameter.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
param | PhysicsServer2D.BodyParameter | — |
VariantBodyGetShapeRid
public static Rid BodyGetShape(Rid body, int shapeIdx);Returns the Rid of the shape with the given index in the body's array of shapes.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
shapeIdx | int | — |
RidBodyGetShapeCountint
public static int BodyGetShapeCount(Rid body);Returns the number of shapes added to the body.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
intBodyGetShapeTransformTransform2D
public static Transform2D BodyGetShapeTransform(Rid body, int shapeIdx);Returns the local transform matrix of the shape with the given index in the area's array of shapes.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
shapeIdx | int | — |
Transform2DBodyGetSpaceRid
public static Rid BodyGetSpace(Rid body);Returns the Rid of the space assigned to the body. Returns an empty Rid if no space is assigned.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
RidBodyGetStateVariant
public static Variant BodyGetState(Rid body, PhysicsServer2D.BodyState state);Returns the value of the given state of the body.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
state | PhysicsServer2D.BodyState | — |
VariantBodyIsOmittingForceIntegrationbool
public static bool BodyIsOmittingForceIntegration(Rid body);Returns true if the body is omitting the standard force integration. See PhysicsServer2D.BodySetOmitForceIntegration.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
boolBodyRemoveCollisionExceptionvoid
public static void BodyRemoveCollisionException(Rid body, Rid exceptedBody);Removes excepted_body from the body's list of collision exceptions, so that collisions with it are no longer ignored.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
exceptedBody | Rid | — |
BodyRemoveShapevoid
public static void BodyRemoveShape(Rid body, int shapeIdx);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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
shapeIdx | int | — |
BodyResetMassPropertiesvoid
public static void BodyResetMassProperties(Rid body);Restores the default inertia and center of mass of the body based on its shapes. This undoes any custom values previously set using PhysicsServer2D.BodySetParam.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
BodySetAxisVelocityvoid
public static void BodySetAxisVelocity(Rid body, Vector2 axisVelocity);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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
axisVelocity | Vector2 | — |
BodySetCollisionLayervoid
public static void BodySetCollisionLayer(Rid body, uint layer);Sets the physics layer or layers the body belongs to, via a bitmask.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
layer | uint | — |
BodySetCollisionMaskvoid
public static void BodySetCollisionMask(Rid body, uint mask);Sets the physics layer or layers the body can collide with, via a bitmask.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
mask | uint | — |
BodySetCollisionPriorityvoid
public static void BodySetCollisionPriority(Rid body, float priority);Sets the body's collision priority. This is used in the depenetration phase of PhysicsServer2D.BodyTestMotion. The higher the priority is, the lower the penetration into the body will be.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
priority | float | — |
BodySetConstantForcevoid
public static void BodySetConstantForce(Rid body, Vector2 force);Sets the body's total constant positional force applied during each physics update.
See PhysicsServer2D.BodyAddConstantForce and PhysicsServer2D.BodyAddConstantCentralForce.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
force | Vector2 | — |
BodySetConstantTorquevoid
public static void BodySetConstantTorque(Rid body, float torque);Sets the body's total constant rotational force applied during each physics update.
See PhysicsServer2D.BodyAddConstantTorque.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
torque | float | — |
BodySetContinuousCollisionDetectionModevoid
public static void BodySetContinuousCollisionDetectionMode(Rid body, PhysicsServer2D.CcdMode mode);Sets the continuous collision detection mode. 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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
mode | PhysicsServer2D.CcdMode | — |
BodySetForceIntegrationCallbackvoid
public static void BodySetForceIntegrationCallback(Rid body, Callable callable, Variant userdata = default);Sets the body's custom force integration callback function to callable. Use an empty Callable ([code skip-lint]Callable()) to clear the custom callback. The function callable will be called every physics tick, before the standard force integration (see [PhysicsServer2D.BodySetOmitForceIntegration](/en/docs/api/physicsserver2d#member-bodysetomitforceintegration-9db2f3f9a1)). It can be used for example to update the body's linear and angular velocity based on contact with other bodies. If userdatais notnull, the function callable` must take the following two parameters:
state: aPhysicsDirectBodyState2Dused to retrieve and modify the body's state,Variant; its value will be theuserdatapassed into this method. Ifuserdataisnull, thencallablemust take only thestateparameter.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
callable | Callable | — |
userdata | Variant | default |
BodySetMaxContactsReportedvoid
public static void BodySetMaxContactsReported(Rid body, int amount);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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
amount | int | — |
BodySetModevoid
public static void BodySetMode(Rid body, PhysicsServer2D.BodyMode mode);Sets the body's mode.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
mode | PhysicsServer2D.BodyMode | — |
BodySetOmitForceIntegrationvoid
public static void BodySetOmitForceIntegration(Rid body, bool enable);Sets whether the body omits the standard force integration. If enable is true, the body will not automatically use applied forces, torques, and damping to update the body's linear and angular velocity. In this case, PhysicsServer2D.BodySetForceIntegrationCallback can be used to manually update the linear and angular velocity instead.
This method is called when the property RigidBody2D.CustomIntegrator is set.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
enable | bool | — |
BodySetParamvoid
public static void BodySetParam(Rid body, PhysicsServer2D.BodyParameter param, Variant value);Sets the value of the given body parameter.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
param | PhysicsServer2D.BodyParameter | — |
value | Variant | — |
BodySetShapevoid
public static void BodySetShape(Rid body, int shapeIdx, Rid shape);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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
shapeIdx | int | — |
shape | Rid | — |
BodySetShapeAsOneWayCollision2 overloads
public static void BodySetShapeAsOneWayCollision(Rid body, int shapeIdx, bool enable, float margin);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 direction in the shape's local space (that is body_get_shape_transform(body, shape_idx).basis_xform(direction).normalized() 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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
shapeIdx | int | — |
enable | bool | — |
margin | float | — |
public static void BodySetShapeAsOneWayCollision(Rid body, int shapeIdx, bool enable, float margin, Vector2? direction = default);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 direction in the shape's local space (that is body_get_shape_transform(body, shape_idx).basis_xform(direction).normalized() 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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
shapeIdx | int | — |
enable | bool | — |
margin | float | — |
direction | Vector2? | default |
directionIf the parameter is null, then the default value is new Vector2(0.0f, 1.0f).
BodySetShapeDisabledvoid
public static void BodySetShapeDisabled(Rid body, int shapeIdx, bool disabled);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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
shapeIdx | int | — |
disabled | bool | — |
BodySetShapeTransformvoid
public static void BodySetShapeTransform(Rid body, int shapeIdx, Transform2D transform);Sets the local transform matrix of the body's shape with the given index.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
shapeIdx | int | — |
transform | Transform2D | — |
BodySetSpacevoid
public static void BodySetSpace(Rid body, Rid space);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 PhysicsServer2D.BodyMode.Rigid, then adding the body to a space will have the following additional effects:
- If the parameter
PhysicsServer2D.BodyParameter.CenterOfMasshas never been set explicitly, then the value of that parameter will be recalculated based on the body's shapes. - If the parameter
PhysicsServer2D.BodyParameter.Inertiais 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. Note: To remove a body from a space without immediately adding it back elsewhere, usePhysicsServer2D.body_set_space(body, RID()).
| Name | Type | Default |
|---|---|---|
body | Rid | — |
space | Rid | — |
BodySetStatevoid
public static void BodySetState(Rid body, PhysicsServer2D.BodyState state, Variant value);Sets the value of a body's state. Note: The state change doesn't take effect immediately. The state will change on the next physics frame.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
state | PhysicsServer2D.BodyState | — |
value | Variant | — |
BodySetStateSyncCallbackvoid
public static void BodySetStateSyncCallback(Rid body, Callable callable);Sets the body's state synchronization callback function to callable. Use an empty Callable ([code skip-lint]Callable()) to clear the callback. The function callablewill 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. The functioncallable` must take the following parameters:
state: aPhysicsDirectBodyState2D, used to retrieve the body's state.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
callable | Callable | — |
BodyTestMotionbool
public static bool BodyTestMotion(Rid body, PhysicsTestMotionParameters2D parameters, PhysicsTestMotionResult2D result = null);Returns true 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.
| Name | Type | Default |
|---|---|---|
body | Rid | — |
parameters | PhysicsTestMotionParameters2D | — |
result | PhysicsTestMotionResult2D | null |
boolCapsuleShapeCreateRid
public static Rid CapsuleShapeCreate();Creates a 2D capsule shape in the physics server, and returns the Rid that identifies it. Use PhysicsServer2D.ShapeSetData to set the capsule's height and radius.
RidCircleShapeCreateRid
public static Rid CircleShapeCreate();Creates a 2D circle shape in the physics server, and returns the Rid that identifies it. Use PhysicsServer2D.ShapeSetData to set the circle's radius.
RidConcavePolygonShapeCreateRid
public static Rid ConcavePolygonShapeCreate();Creates a 2D concave polygon shape in the physics server, and returns the Rid that identifies it. Use PhysicsServer2D.ShapeSetData to set the concave polygon's segments.
RidConvexPolygonShapeCreateRid
public static Rid ConvexPolygonShapeCreate();Creates a 2D convex polygon shape in the physics server, and returns the Rid that identifies it. Use PhysicsServer2D.ShapeSetData to set the convex polygon's points.
RidDampedSpringJointGetParamfloat
public static float DampedSpringJointGetParam(Rid joint, PhysicsServer2D.DampedSpringParam param);Returns the value of the given damped spring joint parameter.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
param | PhysicsServer2D.DampedSpringParam | — |
floatDampedSpringJointSetParamvoid
public static void DampedSpringJointSetParam(Rid joint, PhysicsServer2D.DampedSpringParam param, float value);Sets the value of the given damped spring joint parameter.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
param | PhysicsServer2D.DampedSpringParam | — |
value | float | — |
FreeRidvoid
GetProcessInfoint
public static int GetProcessInfo(PhysicsServer2D.ProcessInfo processInfo);Returns the value of a physics engine state specified by process_info.
| Name | Type | Default |
|---|---|---|
processInfo | PhysicsServer2D.ProcessInfo | — |
intJointClearvoid
public static void JointClear(Rid joint);Destroys the joint with the given Rid, creates a new uninitialized joint, and makes the Rid refer to this new joint.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
JointCreateRid
public static Rid JointCreate();Creates a 2D joint in the physics server, and returns the Rid that identifies it. To set the joint type, use PhysicsServer2D.JointMakeDampedSpring, PhysicsServer2D.JointMakeGroove or PhysicsServer2D.JointMakePin. Use PhysicsServer2D.JointSetParam to set generic joint parameters.
RidJointDisableCollisionsBetweenBodiesvoid
public static void JointDisableCollisionsBetweenBodies(Rid joint, bool disable);Sets whether the bodies attached to the Joint2D will collide with each other.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
disable | bool | — |
JointGetParamfloat
public static float JointGetParam(Rid joint, PhysicsServer2D.JointParam param);Returns the value of the given joint parameter.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
param | PhysicsServer2D.JointParam | — |
floatJointGetTypePhysicsServer2D.JointType
public static PhysicsServer2D.JointType JointGetType(Rid joint);Returns the joint's type.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
PhysicsServer2D.JointTypeJointIsDisabledCollisionsBetweenBodiesbool
public static bool JointIsDisabledCollisionsBetweenBodies(Rid joint);Returns whether the bodies attached to the Joint2D will collide with each other.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
boolJointMakeDampedSpringvoid
public static void JointMakeDampedSpring(Rid joint, Vector2 anchorA, Vector2 anchorB, Rid bodyA, Rid bodyB = default);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 PhysicsServer2D.DampedSpringJointSetParam.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
anchorA | Vector2 | — |
anchorB | Vector2 | — |
bodyA | Rid | — |
bodyB | Rid | default |
JointMakeGroovevoid
public static void JointMakeGroove(Rid joint, Vector2 groove1A, Vector2 groove2A, Vector2 anchorB, Rid bodyA = default, Rid bodyB = default);Makes the joint a groove joint.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
groove1A | Vector2 | — |
groove2A | Vector2 | — |
anchorB | Vector2 | — |
bodyA | Rid | default |
bodyB | Rid | default |
JointMakePinvoid
public static void JointMakePin(Rid joint, Vector2 anchor, Rid bodyA, Rid bodyB = default);Makes the joint a pin joint. If body_b is an empty 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 PhysicsServer2D.PinJointSetParam.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
anchor | Vector2 | — |
bodyA | Rid | — |
bodyB | Rid | default |
JointSetParamvoid
public static void JointSetParam(Rid joint, PhysicsServer2D.JointParam param, float value);Sets the value of the given joint parameter.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
param | PhysicsServer2D.JointParam | — |
value | float | — |
PinJointGetFlagbool
public static bool PinJointGetFlag(Rid joint, PhysicsServer2D.PinJointFlag flag);Gets a pin joint flag.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
flag | PhysicsServer2D.PinJointFlag | — |
boolPinJointGetParamfloat
public static float PinJointGetParam(Rid joint, PhysicsServer2D.PinJointParam param);Returns the value of a pin joint parameter.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
param | PhysicsServer2D.PinJointParam | — |
floatPinJointSetFlagvoid
public static void PinJointSetFlag(Rid joint, PhysicsServer2D.PinJointFlag flag, bool enabled);Sets a pin joint flag.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
flag | PhysicsServer2D.PinJointFlag | — |
enabled | bool | — |
PinJointSetParamvoid
public static void PinJointSetParam(Rid joint, PhysicsServer2D.PinJointParam param, float value);Sets a pin joint parameter.
| Name | Type | Default |
|---|---|---|
joint | Rid | — |
param | PhysicsServer2D.PinJointParam | — |
value | float | — |
RectangleShapeCreateRid
public static Rid RectangleShapeCreate();Creates a 2D rectangle shape in the physics server, and returns the Rid that identifies it. Use PhysicsServer2D.ShapeSetData to set the rectangle's half-extents.
RidSegmentShapeCreateRid
public static Rid SegmentShapeCreate();Creates a 2D segment shape in the physics server, and returns the Rid that identifies it. Use PhysicsServer2D.ShapeSetData to set the segment's start and end points.
RidSeparationRayShapeCreateRid
public static Rid SeparationRayShapeCreate();Creates a 2D separation ray shape in the physics server, and returns the Rid that identifies it. Use PhysicsServer2D.ShapeSetData to set the shape's length and slide_on_slope properties.
RidSetActivevoid
public static void SetActive(bool active);Activates or deactivates the 2D physics server. If active is false, then the physics server will not do anything in its physics step.
| Name | Type | Default |
|---|---|---|
active | bool | — |
ShapeGetDataVariant
public static Variant ShapeGetData(Rid shape);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 PhysicsServer2D.ShapeSetData for the precise format of this data in each case.
| Name | Type | Default |
|---|---|---|
shape | Rid | — |
VariantShapeGetTypePhysicsServer2D.ShapeType
public static PhysicsServer2D.ShapeType ShapeGetType(Rid shape);Returns the shape's type.
| Name | Type | Default |
|---|---|---|
shape | Rid | — |
PhysicsServer2D.ShapeTypeShapeSetDatavoid
public static void ShapeSetData(Rid shape, Variant data);Sets the shape data that defines the configuration of the shape. The data to be passed depends on the shape's type (see PhysicsServer2D.ShapeGetType):
PhysicsServer2D.ShapeType.WorldBoundary: an array of length two containing aVector2normaldirection and a [float] distanced,PhysicsServer2D.ShapeType.SeparationRay: a dictionary containing the keylengthwith a [float] value and the keyslide_on_slopewith a [bool] value,PhysicsServer2D.ShapeType.Segment: aRect2rectcontaining the first point of the segment inrect.positionand the second point of the segment inrect.size,PhysicsServer2D.ShapeType.Circle: a [float]radius,PhysicsServer2D.ShapeType.Rectangle: aVector2half_extents,PhysicsServer2D.ShapeType.Capsule: an array of length two (or aVector2) containing a [float]heightand a [float]radius,PhysicsServer2D.ShapeType.ConvexPolygon: either aVector2[]of points defining a convex polygon in counterclockwise order (the clockwise outward normal of each segment formed by consecutive points is calculated internally), or afloat[]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,PhysicsServer2D.ShapeType.ConcavePolygon: aVector2[]of length divisible by two (each pair of points forms one segment). Warning: In the case ofPhysicsServer2D.ShapeType.ConvexPolygon, this method does not check if the points supplied actually form a convex polygon (unlike theCollisionPolygon2D.Polygonproperty).
| Name | Type | Default |
|---|---|---|
shape | Rid | — |
data | Variant | — |
SpaceCreateRid
public static Rid SpaceCreate();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.
RidSpaceGetDirectStatePhysicsDirectSpaceState2D
public static PhysicsDirectSpaceState2D SpaceGetDirectState(Rid space);Returns the state of a space, a PhysicsDirectSpaceState2D. This object can be used for collision/intersection queries.
| Name | Type | Default |
|---|---|---|
space | Rid | — |
PhysicsDirectSpaceState2DSpaceGetParamfloat
public static float SpaceGetParam(Rid space, PhysicsServer2D.SpaceParameter param);Returns the value of the given space parameter.
| Name | Type | Default |
|---|---|---|
space | Rid | — |
param | PhysicsServer2D.SpaceParameter | — |
floatSpaceIsActivebool
public static bool SpaceIsActive(Rid space);Returns true if the space is active.
| Name | Type | Default |
|---|---|---|
space | Rid | — |
boolSpaceSetActivevoid
public static void SpaceSetActive(Rid space, bool active);Activates or deactivates the space. If active is false, then the physics server will not do anything with this space in its physics step.
| Name | Type | Default |
|---|---|---|
space | Rid | — |
active | bool | — |
SpaceSetParamvoid
public static void SpaceSetParam(Rid space, PhysicsServer2D.SpaceParameter param, float value);Sets the value of the given space parameter.
| Name | Type | Default |
|---|---|---|
space | Rid | — |
param | PhysicsServer2D.SpaceParameter | — |
value | float | — |
WorldBoundaryShapeCreateRid
public static Rid WorldBoundaryShapeCreate();Creates a 2D world boundary shape in the physics server, and returns the Rid that identifies it. Use PhysicsServer2D.ShapeSetData to set the shape's normal direction and distance properties.
RidPhysicsServer2D.AreaBodyStatus
| Value | Description |
|---|---|
Added = 0 | The value of the first parameter and area callback function receives, when an object enters one of its shapes. |
Removed = 1 | The value of the first parameter and area callback function receives, when an object exits one of its shapes. |
PhysicsServer2D.AreaParameter
| Value | Description |
|---|---|
AngularDamp = 8 | Constant to set/get the angular damping factor of an area. The default value of this parameter is |
AngularDampOverrideMode = 7 | Constant to set/get angular damping override mode in an area. See |
Gravity = 1 | Constant to set/get gravity strength in an area. The default value of this parameter is |
GravityIsPoint = 3 | 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 |
GravityOverrideMode = 0 | Constant to set/get gravity override mode in an area. See |
GravityPointUnitDistance = 4 | Constant to set/get the distance at which the gravity strength is equal to the gravity controlled by |
GravityVector = 2 | Constant to set/get gravity vector/center in an area. The default value of this parameter is |
LinearDamp = 6 | Constant to set/get the linear damping factor of an area. The default value of this parameter is |
LinearDampOverrideMode = 5 | Constant to set/get linear damping override mode in an area. See |
Priority = 9 | Constant to set/get the priority (order of processing) of an area. The default value of this parameter is |
PhysicsServer2D.AreaSpaceOverrideMode
| Value | Description |
|---|---|
Combine = 1 | 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. |
CombineReplace = 2 | 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. |
Disabled = 0 | This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them. |
Replace = 3 | This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas. |
ReplaceCombine = 4 | This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one. |
PhysicsServer2D.BodyDampMode
| Value | Description |
|---|---|
Combine = 0 | The body's damping value is added to any value set in areas or the default value. |
Replace = 1 | The body's damping value replaces any value set in areas or the default value. |
PhysicsServer2D.BodyMode
| Value | Description |
|---|---|
Kinematic = 1 | Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path. |
Rigid = 2 | Constant for rigid bodies. In this mode, a body can be pushed by other bodies and has forces applied. |
RigidLinear = 3 | Constant for linear rigid bodies. In this mode, a body can not rotate, and only its linear velocity is affected by external forces. |
Static = 0 | 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. |
PhysicsServer2D.BodyParameter
| Value | Description |
|---|---|
AngularDamp = 9 | Constant to set/get a body's angular damping factor. The default value of this parameter is |
AngularDampMode = 7 | Constant to set/get a body's angular damping mode. See |
Bounce = 0 | Constant to set/get a body's bounce factor. The default value of this parameter is |
CenterOfMass = 4 | 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 |
Friction = 1 | Constant to set/get a body's friction. The default value of this parameter is |
GravityScale = 5 | Constant to set/get a body's gravity multiplier. The default value of this parameter is |
Inertia = 3 | Constant to set/get a body's inertia. The default value of this parameter is |
LinearDamp = 8 | Constant to set/get a body's linear damping factor. The default value of this parameter is |
LinearDampMode = 6 | Constant to set/get a body's linear damping mode. See |
Mass = 2 | Constant to set/get a body's mass. The default value of this parameter is
|
Max = 10 | Represents the size of the |
PhysicsServer2D.BodyState
| Value | Description |
|---|---|
AngularVelocity = 2 | Constant to set/get the current angular velocity of the body. |
CanSleep = 4 | Constant to set/get whether the body can sleep. |
LinearVelocity = 1 | Constant to set/get the current linear velocity of the body. |
Sleeping = 3 | Constant to sleep/wake up a body, or to get whether it is sleeping. |
Transform = 0 | Constant to set/get the current transform matrix of the body. |
PhysicsServer2D.CcdMode
| Value | Description |
|---|---|
CastRay = 1 | Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise. |
CastShape = 2 | Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise. |
Disabled = 0 | Disables continuous collision detection. This is the fastest way to detect body collisions, but it can miss small and/or fast-moving objects. |
PhysicsServer2D.DampedSpringParam
| Value | Description |
|---|---|
Damping = 2 | 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 |
RestLength = 0 | 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. |
Stiffness = 1 | 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 |
PhysicsServer2D.JointParam
| Value | Description |
|---|---|
Bias = 0 | 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 |
MaxBias = 1 | Constant to set/get the maximum speed with which the joint can apply corrections. The default value of this parameter is |
MaxForce = 2 | 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 |
PhysicsServer2D.JointType
| Value | Description |
|---|---|
DampedSpring = 2 | Constant to create damped spring joints. |
Groove = 1 | Constant to create groove joints. |
Max = 3 | Represents the size of the |
Pin = 0 | Constant to create pin joints. |
PhysicsServer2D.PinJointFlag
| Value | Description |
|---|---|
AngularLimitEnabled = 0 | If |
MotorEnabled = 1 | If |
PhysicsServer2D.PinJointParam
| Value | Description |
|---|---|
LimitLower = 2 | The minimum rotation around the pin. |
LimitUpper = 1 | The maximum rotation around the pin. |
MotorTargetVelocity = 3 | Target speed for the motor. In radians per second. |
Softness = 0 | Constant to set/get a how much the bond of the pin joint can flex. The default value of this parameter is |
PhysicsServer2D.ProcessInfo
| Value | Description |
|---|---|
ActiveObjects = 0 | Constant to get the number of objects that are not sleeping. |
CollisionPairs = 1 | Constant to get the number of possible collisions. |
IslandCount = 2 | Constant to get the number of space regions where a collision could occur. |
PhysicsServer2D.ShapeType
| Value | Description |
|---|---|
Capsule = 5 | 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. |
Circle = 3 | 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. |
ConcavePolygon = 7 | 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. |
ConvexPolygon = 6 | 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. |
Custom = 8 | This constant is used internally by the engine. Any attempt to create this kind of shape results in an error. |
Rectangle = 4 | 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. |
Segment = 2 | 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. |
SeparationRay = 1 | 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. |
WorldBoundary = 0 | 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. |
PhysicsServer2D.SpaceParameter
| Value | Description |
|---|---|
BodyAngularVelocitySleepThreshold = 5 | 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 |
BodyLinearVelocitySleepThreshold = 4 | 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 |
BodyTimeToSleep = 6 | 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 |
ConstraintDefaultBias = 7 | 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 |
ContactDefaultBias = 3 | 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 |
ContactMaxAllowedPenetration = 2 | 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 |
ContactMaxSeparation = 1 | 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 |
ContactRecycleRadius = 0 | 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 |
SolverIterations = 8 | 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 |