reckfellENGINE

PhysicsServer2D

A server interface for low-level 2D physics access.

On this page
class PhysicsServer2DReckfellSharp

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 PhysicsServer2D may 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
# Singleton
C#
public static PhysicsServer2DInstance Singleton { get; }

Methods120

AreaAddShapevoid
# AreaAddShape
C#
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.

Parameters
NameTypeDefault
areaRid—
shapeRid—
transformTransform2D?default
disabledboolfalse
transform

If the parameter is null, then the default value is Transform2D.Identity.

AreaAttachCanvasInstanceIdvoid
# AreaAttachCanvasInstanceId
C#
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.

Parameters
NameTypeDefault
areaRid—
idulong—
AreaAttachObjectInstanceIdvoid
# AreaAttachObjectInstanceId
C#
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.

Parameters
NameTypeDefault
areaRid—
idulong—
AreaClearShapesvoid
# AreaClearShapes
C#
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.

Parameters
NameTypeDefault
areaRid—
AreaCreateRid
# AreaCreate
C#
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.

Returns Rid
AreaGetCanvasInstanceIdulong
# AreaGetCanvasInstanceId
C#
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.

Parameters
NameTypeDefault
areaRid—
Returns ulong
AreaGetCollisionLayeruint
# AreaGetCollisionLayer
C#
public static uint AreaGetCollisionLayer(Rid area);

Returns the physics layer or layers the area belongs to, as a bitmask.

Parameters
NameTypeDefault
areaRid—
Returns uint
AreaGetCollisionMaskuint
# AreaGetCollisionMask
C#
public static uint AreaGetCollisionMask(Rid area);

Returns the physics layer or layers the area can contact with, as a bitmask.

Parameters
NameTypeDefault
areaRid—
Returns uint
AreaGetObjectInstanceIdulong
# AreaGetObjectInstanceId
C#
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.

Parameters
NameTypeDefault
areaRid—
Returns ulong
AreaGetParamVariant
# AreaGetParam
C#
public static Variant AreaGetParam(Rid area, PhysicsServer2D.AreaParameter param);

Returns the value of the given area parameter.

Parameters
NameTypeDefault
areaRid—
paramPhysicsServer2D.AreaParameter—
Returns Variant
AreaGetShapeRid
# AreaGetShape
C#
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.

Parameters
NameTypeDefault
areaRid—
shapeIdxint—
Returns Rid
AreaGetShapeCountint
# AreaGetShapeCount
C#
public static int AreaGetShapeCount(Rid area);

Returns the number of shapes added to the area.

Parameters
NameTypeDefault
areaRid—
Returns int
AreaGetShapeTransformTransform2D
# AreaGetShapeTransform
C#
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.

Parameters
NameTypeDefault
areaRid—
shapeIdxint—
Returns Transform2D
AreaGetSpaceRid
# AreaGetSpace
C#
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.

Parameters
NameTypeDefault
areaRid—
Returns Rid
AreaGetTransformTransform2D
# AreaGetTransform
C#
public static Transform2D AreaGetTransform(Rid area);

Returns the transform matrix of the area.

Parameters
NameTypeDefault
areaRid—
Returns Transform2D
AreaRemoveShapevoid
# AreaRemoveShape
C#
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.

Parameters
NameTypeDefault
areaRid—
shapeIdxint—
AreaSetAreaMonitorCallbackvoid
# AreaSetAreaMonitorCallback
C#
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:

  1. an integer status: either PhysicsServer2D.AreaBodyStatus.Added or PhysicsServer2D.AreaBodyStatus.Removed depending on whether the other area's shape entered or exited the area,
  2. an Rid area_rid: the Rid of the other area that entered or exited the area,
  3. an integer instance_id: the ObjectID attached to the other area,
  4. an integer area_shape_idx: the index of the shape of the other area that entered or exited the area,
  5. 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.
Parameters
NameTypeDefault
areaRid—
callbackCallable—
AreaSetCollisionLayervoid
# AreaSetCollisionLayer
C#
public static void AreaSetCollisionLayer(Rid area, uint layer);

Assigns the area to one or many physics layers, via a bitmask.

Parameters
NameTypeDefault
areaRid—
layeruint—
AreaSetCollisionMaskvoid
# AreaSetCollisionMask
C#
public static void AreaSetCollisionMask(Rid area, uint mask);

Sets which physics layers the area will monitor, via a bitmask.

Parameters
NameTypeDefault
areaRid—
maskuint—
AreaSetMonitorCallbackvoid
# AreaSetMonitorCallback
C#
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:

  1. an integer status: either PhysicsServer2D.AreaBodyStatus.Added or PhysicsServer2D.AreaBodyStatus.Removed depending on whether the other body shape entered or exited the area,
  2. an Rid body_rid: the Rid of the body that entered or exited the area,
  3. an integer instance_id: the ObjectID attached to the body,
  4. an integer body_shape_idx: the index of the shape of the body that entered or exited the area,
  5. 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.
Parameters
NameTypeDefault
areaRid—
callbackCallable—
AreaSetMonitorablevoid
# AreaSetMonitorable
C#
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.

Parameters
NameTypeDefault
areaRid—
monitorablebool—
AreaSetParamvoid
# AreaSetParam
C#
public static void AreaSetParam(Rid area, PhysicsServer2D.AreaParameter param, Variant value);

Sets the value of the given area parameter.

Parameters
NameTypeDefault
areaRid—
paramPhysicsServer2D.AreaParameter—
valueVariant—
AreaSetShapevoid
# AreaSetShape
C#
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.

Parameters
NameTypeDefault
areaRid—
shapeIdxint—
shapeRid—
AreaSetShapeDisabledvoid
# AreaSetShapeDisabled
C#
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.

Parameters
NameTypeDefault
areaRid—
shapeIdxint—
disabledbool—
AreaSetShapeTransformvoid
# AreaSetShapeTransform
C#
public static void AreaSetShapeTransform(Rid area, int shapeIdx, Transform2D transform);

Sets the local transform matrix of the area's shape with the given index.

Parameters
NameTypeDefault
areaRid—
shapeIdxint—
transformTransform2D—
AreaSetSpacevoid
# AreaSetSpace
C#
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()).

Parameters
NameTypeDefault
areaRid—
spaceRid—
AreaSetTransformvoid
# AreaSetTransform
C#
public static void AreaSetTransform(Rid area, Transform2D transform);

Sets the transform matrix of the area.

Parameters
NameTypeDefault
areaRid—
transformTransform2D—
BodyAddCollisionExceptionvoid
# BodyAddCollisionException
C#
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.

Parameters
NameTypeDefault
bodyRid—
exceptedBodyRid—
BodyAddConstantCentralForcevoid
# BodyAddConstantCentralForce
C#
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.

Parameters
NameTypeDefault
bodyRid—
forceVector2—
BodyAddConstantForcevoid
# BodyAddConstantForce
C#
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.

Parameters
NameTypeDefault
bodyRid—
forceVector2—
positionVector2?default
position

If the parameter is null, then the default value is new Vector2(0.0f, 0.0f).

BodyAddConstantTorquevoid
# BodyAddConstantTorque
C#
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).

Parameters
NameTypeDefault
bodyRid—
torquefloat—
BodyAddShapevoid
# BodyAddShape
C#
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.

Parameters
NameTypeDefault
bodyRid—
shapeRid—
transformTransform2D?default
disabledboolfalse
transform

If the parameter is null, then the default value is Transform2D.Identity.

BodyApplyCentralForcevoid
# BodyApplyCentralForce
C#
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.

Parameters
NameTypeDefault
bodyRid—
forceVector2—
BodyApplyCentralImpulsevoid
# BodyApplyCentralImpulse
C#
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.

Parameters
NameTypeDefault
bodyRid—
impulseVector2—
BodyApplyForcevoid
# BodyApplyForce
C#
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.

Parameters
NameTypeDefault
bodyRid—
forceVector2—
positionVector2?default
position

If the parameter is null, then the default value is new Vector2(0.0f, 0.0f).

BodyApplyImpulsevoid
# BodyApplyImpulse
C#
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.

Parameters
NameTypeDefault
bodyRid—
impulseVector2—
positionVector2?default
position

If the parameter is null, then the default value is new Vector2(0.0f, 0.0f).

BodyApplyTorquevoid
# BodyApplyTorque
C#
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.

Parameters
NameTypeDefault
bodyRid—
torquefloat—
BodyApplyTorqueImpulsevoid
# BodyApplyTorqueImpulse
C#
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).

Parameters
NameTypeDefault
bodyRid—
impulsefloat—
BodyAttachCanvasInstanceIdvoid
# BodyAttachCanvasInstanceId
C#
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.

Parameters
NameTypeDefault
bodyRid—
idulong—
BodyAttachObjectInstanceIdvoid
# BodyAttachObjectInstanceId
C#
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.

Parameters
NameTypeDefault
bodyRid—
idulong—
BodyClearShapesvoid
# BodyClearShapes
C#
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.

Parameters
NameTypeDefault
bodyRid—
BodyCreateRid
# BodyCreate
C#
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.

Returns Rid
BodyGetCanvasInstanceIdulong
# BodyGetCanvasInstanceId
C#
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.

Parameters
NameTypeDefault
bodyRid—
Returns ulong
BodyGetCollisionLayeruint
# BodyGetCollisionLayer
C#
public static uint BodyGetCollisionLayer(Rid body);

Returns the physics layer or layers the body belongs to, as a bitmask.

Parameters
NameTypeDefault
bodyRid—
Returns uint
BodyGetCollisionMaskuint
# BodyGetCollisionMask
C#
public static uint BodyGetCollisionMask(Rid body);

Returns the physics layer or layers the body can collide with, as a bitmask.

Parameters
NameTypeDefault
bodyRid—
Returns uint
BodyGetCollisionPriorityfloat
# BodyGetCollisionPriority
C#
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.

Parameters
NameTypeDefault
bodyRid—
Returns float
BodyGetConstantForceVector2
# BodyGetConstantForce
C#
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.

Parameters
NameTypeDefault
bodyRid—
Returns Vector2
BodyGetConstantTorquefloat
# BodyGetConstantTorque
C#
public static float BodyGetConstantTorque(Rid body);

Returns the body's total constant rotational force applied during each physics update. See PhysicsServer2D.BodyAddConstantTorque.

Parameters
NameTypeDefault
bodyRid—
Returns float
BodyGetContinuousCollisionDetectionModePhysicsServer2D.CcdMode
# BodyGetContinuousCollisionDetectionMode
C#
public static PhysicsServer2D.CcdMode BodyGetContinuousCollisionDetectionMode(Rid body);

Returns the body's continuous collision detection mode.

Parameters
NameTypeDefault
bodyRid—
Returns PhysicsServer2D.CcdMode
BodyGetDirectStatePhysicsDirectBodyState2D
# BodyGetDirectState
C#
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.

Parameters
NameTypeDefault
bodyRid—
Returns PhysicsDirectBodyState2D
BodyGetMaxContactsReportedint
# BodyGetMaxContactsReported
C#
public static int BodyGetMaxContactsReported(Rid body);

Returns the maximum number of contacts that the body can report. See PhysicsServer2D.BodySetMaxContactsReported.

Parameters
NameTypeDefault
bodyRid—
Returns int
BodyGetModePhysicsServer2D.BodyMode
# BodyGetMode
C#
public static PhysicsServer2D.BodyMode BodyGetMode(Rid body);

Returns the body's mode.

Parameters
NameTypeDefault
bodyRid—
Returns PhysicsServer2D.BodyMode
BodyGetObjectInstanceIdulong
# BodyGetObjectInstanceId
C#
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.

Parameters
NameTypeDefault
bodyRid—
Returns ulong
BodyGetParamVariant
# BodyGetParam
C#
public static Variant BodyGetParam(Rid body, PhysicsServer2D.BodyParameter param);

Returns the value of the given body parameter.

Parameters
NameTypeDefault
bodyRid—
paramPhysicsServer2D.BodyParameter—
Returns Variant
BodyGetShapeRid
# BodyGetShape
C#
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.

Parameters
NameTypeDefault
bodyRid—
shapeIdxint—
Returns Rid
BodyGetShapeCountint
# BodyGetShapeCount
C#
public static int BodyGetShapeCount(Rid body);

Returns the number of shapes added to the body.

Parameters
NameTypeDefault
bodyRid—
Returns int
BodyGetShapeTransformTransform2D
# BodyGetShapeTransform
C#
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.

Parameters
NameTypeDefault
bodyRid—
shapeIdxint—
Returns Transform2D
BodyGetSpaceRid
# BodyGetSpace
C#
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.

Parameters
NameTypeDefault
bodyRid—
Returns Rid
BodyGetStateVariant
# BodyGetState
C#
public static Variant BodyGetState(Rid body, PhysicsServer2D.BodyState state);

Returns the value of the given state of the body.

Parameters
NameTypeDefault
bodyRid—
statePhysicsServer2D.BodyState—
Returns Variant
BodyIsOmittingForceIntegrationbool
# BodyIsOmittingForceIntegration
C#
public static bool BodyIsOmittingForceIntegration(Rid body);

Returns true if the body is omitting the standard force integration. See PhysicsServer2D.BodySetOmitForceIntegration.

Parameters
NameTypeDefault
bodyRid—
Returns bool
BodyRemoveCollisionExceptionvoid
# BodyRemoveCollisionException
C#
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.

Parameters
NameTypeDefault
bodyRid—
exceptedBodyRid—
BodyRemoveShapevoid
# BodyRemoveShape
C#
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.

Parameters
NameTypeDefault
bodyRid—
shapeIdxint—
BodyResetMassPropertiesvoid
# BodyResetMassProperties
C#
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.

Parameters
NameTypeDefault
bodyRid—
BodySetAxisVelocityvoid
# BodySetAxisVelocity
C#
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.

Parameters
NameTypeDefault
bodyRid—
axisVelocityVector2—
BodySetCollisionLayervoid
# BodySetCollisionLayer
C#
public static void BodySetCollisionLayer(Rid body, uint layer);

Sets the physics layer or layers the body belongs to, via a bitmask.

Parameters
NameTypeDefault
bodyRid—
layeruint—
BodySetCollisionMaskvoid
# BodySetCollisionMask
C#
public static void BodySetCollisionMask(Rid body, uint mask);

Sets the physics layer or layers the body can collide with, via a bitmask.

Parameters
NameTypeDefault
bodyRid—
maskuint—
BodySetCollisionPriorityvoid
# BodySetCollisionPriority
C#
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.

Parameters
NameTypeDefault
bodyRid—
priorityfloat—
BodySetConstantForcevoid
# BodySetConstantForce
C#
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.

Parameters
NameTypeDefault
bodyRid—
forceVector2—
BodySetConstantTorquevoid
# BodySetConstantTorque
C#
public static void BodySetConstantTorque(Rid body, float torque);

Sets the body's total constant rotational force applied during each physics update. See PhysicsServer2D.BodyAddConstantTorque.

Parameters
NameTypeDefault
bodyRid—
torquefloat—
BodySetContinuousCollisionDetectionModevoid
# BodySetContinuousCollisionDetectionMode
C#
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.

Parameters
NameTypeDefault
bodyRid—
modePhysicsServer2D.CcdMode—
BodySetForceIntegrationCallbackvoid
# BodySetForceIntegrationCallback
C#
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:

  1. state: a PhysicsDirectBodyState2D used to retrieve and modify the body's state,
  2. Variant; its value will be the userdata passed into this method. If userdata is null, then callable must take only the state parameter.
Parameters
NameTypeDefault
bodyRid—
callableCallable—
userdataVariantdefault
BodySetMaxContactsReportedvoid
# BodySetMaxContactsReported
C#
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.

Parameters
NameTypeDefault
bodyRid—
amountint—
BodySetModevoid
# BodySetMode
C#
public static void BodySetMode(Rid body, PhysicsServer2D.BodyMode mode);

Sets the body's mode.

Parameters
NameTypeDefault
bodyRid—
modePhysicsServer2D.BodyMode—
BodySetOmitForceIntegrationvoid
# BodySetOmitForceIntegration
C#
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.

Parameters
NameTypeDefault
bodyRid—
enablebool—
BodySetParamvoid
# BodySetParam
C#
public static void BodySetParam(Rid body, PhysicsServer2D.BodyParameter param, Variant value);

Sets the value of the given body parameter.

Parameters
NameTypeDefault
bodyRid—
paramPhysicsServer2D.BodyParameter—
valueVariant—
BodySetShapevoid
# BodySetShape
C#
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.

Parameters
NameTypeDefault
bodyRid—
shapeIdxint—
shapeRid—
BodySetShapeAsOneWayCollision2 overloads
# BodySetShapeAsOneWayCollision · 1/2
C#
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.

Parameters
NameTypeDefault
bodyRid—
shapeIdxint—
enablebool—
marginfloat—
# BodySetShapeAsOneWayCollision · 2/2
C#
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.

Parameters
NameTypeDefault
bodyRid—
shapeIdxint—
enablebool—
marginfloat—
directionVector2?default
direction

If the parameter is null, then the default value is new Vector2(0.0f, 1.0f).

BodySetShapeDisabledvoid
# BodySetShapeDisabled
C#
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.

Parameters
NameTypeDefault
bodyRid—
shapeIdxint—
disabledbool—
BodySetShapeTransformvoid
# BodySetShapeTransform
C#
public static void BodySetShapeTransform(Rid body, int shapeIdx, Transform2D transform);

Sets the local transform matrix of the body's shape with the given index.

Parameters
NameTypeDefault
bodyRid—
shapeIdxint—
transformTransform2D—
BodySetSpacevoid
# BodySetSpace
C#
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.CenterOfMass has never been set explicitly, then the value of that parameter will be recalculated based on the body's shapes.
  • If the parameter PhysicsServer2D.BodyParameter.Inertia is set to a value <= 0.0, then the value of that parameter will be recalculated based on the body's shapes, mass, and center of mass. Note: To remove a body from a space without immediately adding it back elsewhere, use PhysicsServer2D.body_set_space(body, RID()).
Parameters
NameTypeDefault
bodyRid—
spaceRid—
BodySetStatevoid
# BodySetState
C#
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.

Parameters
NameTypeDefault
bodyRid—
statePhysicsServer2D.BodyState—
valueVariant—
BodySetStateSyncCallbackvoid
# BodySetStateSyncCallback
C#
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:

  1. state: a PhysicsDirectBodyState2D, used to retrieve the body's state.
Parameters
NameTypeDefault
bodyRid—
callableCallable—
BodyTestMotionbool
# BodyTestMotion
C#
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.

Parameters
NameTypeDefault
bodyRid—
parametersPhysicsTestMotionParameters2D—
resultPhysicsTestMotionResult2Dnull
Returns bool
CapsuleShapeCreateRid
# CapsuleShapeCreate
C#
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.

Returns Rid
CircleShapeCreateRid
# CircleShapeCreate
C#
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.

Returns Rid
ConcavePolygonShapeCreateRid
# ConcavePolygonShapeCreate
C#
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.

Returns Rid
ConvexPolygonShapeCreateRid
# ConvexPolygonShapeCreate
C#
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.

Returns Rid
DampedSpringJointGetParamfloat
# DampedSpringJointGetParam
C#
public static float DampedSpringJointGetParam(Rid joint, PhysicsServer2D.DampedSpringParam param);

Returns the value of the given damped spring joint parameter.

Parameters
NameTypeDefault
jointRid—
paramPhysicsServer2D.DampedSpringParam—
Returns float
DampedSpringJointSetParamvoid
# DampedSpringJointSetParam
C#
public static void DampedSpringJointSetParam(Rid joint, PhysicsServer2D.DampedSpringParam param, float value);

Sets the value of the given damped spring joint parameter.

Parameters
NameTypeDefault
jointRid—
paramPhysicsServer2D.DampedSpringParam—
valuefloat—
FreeRidvoid
# FreeRid
C#
public static void FreeRid(Rid rid);

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.

Parameters
NameTypeDefault
ridRid—
GetProcessInfoint
# GetProcessInfo
C#
public static int GetProcessInfo(PhysicsServer2D.ProcessInfo processInfo);

Returns the value of a physics engine state specified by process_info.

Parameters
NameTypeDefault
processInfoPhysicsServer2D.ProcessInfo—
Returns int
JointClearvoid
# JointClear
C#
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.

Parameters
NameTypeDefault
jointRid—
JointCreateRid
# JointCreate
C#
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.

Returns Rid
JointDisableCollisionsBetweenBodiesvoid
# JointDisableCollisionsBetweenBodies
C#
public static void JointDisableCollisionsBetweenBodies(Rid joint, bool disable);

Sets whether the bodies attached to the Joint2D will collide with each other.

Parameters
NameTypeDefault
jointRid—
disablebool—
JointGetParamfloat
# JointGetParam
C#
public static float JointGetParam(Rid joint, PhysicsServer2D.JointParam param);

Returns the value of the given joint parameter.

Parameters
NameTypeDefault
jointRid—
paramPhysicsServer2D.JointParam—
Returns float
JointGetTypePhysicsServer2D.JointType
# JointGetType
C#
public static PhysicsServer2D.JointType JointGetType(Rid joint);

Returns the joint's type.

Parameters
NameTypeDefault
jointRid—
Returns PhysicsServer2D.JointType
JointIsDisabledCollisionsBetweenBodiesbool
# JointIsDisabledCollisionsBetweenBodies
C#
public static bool JointIsDisabledCollisionsBetweenBodies(Rid joint);

Returns whether the bodies attached to the Joint2D will collide with each other.

Parameters
NameTypeDefault
jointRid—
Returns bool
JointMakeDampedSpringvoid
# JointMakeDampedSpring
C#
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.

Parameters
NameTypeDefault
jointRid—
anchorAVector2—
anchorBVector2—
bodyARid—
bodyBRiddefault
JointMakeGroovevoid
# JointMakeGroove
C#
public static void JointMakeGroove(Rid joint, Vector2 groove1A, Vector2 groove2A, Vector2 anchorB, Rid bodyA = default, Rid bodyB = default);

Makes the joint a groove joint.

Parameters
NameTypeDefault
jointRid—
groove1AVector2—
groove2AVector2—
anchorBVector2—
bodyARiddefault
bodyBRiddefault
JointMakePinvoid
# JointMakePin
C#
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.

Parameters
NameTypeDefault
jointRid—
anchorVector2—
bodyARid—
bodyBRiddefault
JointSetParamvoid
# JointSetParam
C#
public static void JointSetParam(Rid joint, PhysicsServer2D.JointParam param, float value);

Sets the value of the given joint parameter.

Parameters
NameTypeDefault
jointRid—
paramPhysicsServer2D.JointParam—
valuefloat—
PinJointGetFlagbool
# PinJointGetFlag
C#
public static bool PinJointGetFlag(Rid joint, PhysicsServer2D.PinJointFlag flag);

Gets a pin joint flag.

Parameters
NameTypeDefault
jointRid—
flagPhysicsServer2D.PinJointFlag—
Returns bool
PinJointGetParamfloat
# PinJointGetParam
C#
public static float PinJointGetParam(Rid joint, PhysicsServer2D.PinJointParam param);

Returns the value of a pin joint parameter.

Parameters
NameTypeDefault
jointRid—
paramPhysicsServer2D.PinJointParam—
Returns float
PinJointSetFlagvoid
# PinJointSetFlag
C#
public static void PinJointSetFlag(Rid joint, PhysicsServer2D.PinJointFlag flag, bool enabled);

Sets a pin joint flag.

Parameters
NameTypeDefault
jointRid—
flagPhysicsServer2D.PinJointFlag—
enabledbool—
PinJointSetParamvoid
# PinJointSetParam
C#
public static void PinJointSetParam(Rid joint, PhysicsServer2D.PinJointParam param, float value);

Sets a pin joint parameter.

Parameters
NameTypeDefault
jointRid—
paramPhysicsServer2D.PinJointParam—
valuefloat—
RectangleShapeCreateRid
# RectangleShapeCreate
C#
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.

Returns Rid
SegmentShapeCreateRid
# SegmentShapeCreate
C#
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.

Returns Rid
SeparationRayShapeCreateRid
# SeparationRayShapeCreate
C#
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.

Returns Rid
SetActivevoid
# SetActive
C#
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.

Parameters
NameTypeDefault
activebool—
ShapeGetDataVariant
# ShapeGetData
C#
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.

Parameters
NameTypeDefault
shapeRid—
Returns Variant
ShapeGetTypePhysicsServer2D.ShapeType
# ShapeGetType
C#
public static PhysicsServer2D.ShapeType ShapeGetType(Rid shape);

Returns the shape's type.

Parameters
NameTypeDefault
shapeRid—
Returns PhysicsServer2D.ShapeType
ShapeSetDatavoid
# ShapeSetData
C#
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):

Parameters
NameTypeDefault
shapeRid—
dataVariant—
SpaceCreateRid
# SpaceCreate
C#
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.

Returns Rid
SpaceGetDirectStatePhysicsDirectSpaceState2D
# SpaceGetDirectState
C#
public static PhysicsDirectSpaceState2D SpaceGetDirectState(Rid space);

Returns the state of a space, a PhysicsDirectSpaceState2D. This object can be used for collision/intersection queries.

Parameters
NameTypeDefault
spaceRid—
Returns PhysicsDirectSpaceState2D
SpaceGetParamfloat
# SpaceGetParam
C#
public static float SpaceGetParam(Rid space, PhysicsServer2D.SpaceParameter param);

Returns the value of the given space parameter.

Parameters
NameTypeDefault
spaceRid—
paramPhysicsServer2D.SpaceParameter—
Returns float
SpaceIsActivebool
# SpaceIsActive
C#
public static bool SpaceIsActive(Rid space);

Returns true if the space is active.

Parameters
NameTypeDefault
spaceRid—
Returns bool
SpaceSetActivevoid
# SpaceSetActive
C#
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.

Parameters
NameTypeDefault
spaceRid—
activebool—
SpaceSetParamvoid
# SpaceSetParam
C#
public static void SpaceSetParam(Rid space, PhysicsServer2D.SpaceParameter param, float value);

Sets the value of the given space parameter.

Parameters
NameTypeDefault
spaceRid—
paramPhysicsServer2D.SpaceParameter—
valuefloat—
WorldBoundaryShapeCreateRid
# WorldBoundaryShapeCreate
C#
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.

Returns Rid

PhysicsServer2D.AreaBodyStatus

ValueDescription
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

ValueDescription
AngularDamp = 8

Constant to set/get the angular damping factor of an area. The default value of this parameter is 1.0.

AngularDampOverrideMode = 7

Constant to set/get angular damping override mode in an area. See PhysicsServer2D.AreaSpaceOverrideMode for possible values. The default value of this parameter is PhysicsServer2D.AreaSpaceOverrideMode.Disabled.

Gravity = 1

Constant to set/get gravity strength in an area. The default value of this parameter is 9.80665.

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 false.

GravityOverrideMode = 0

Constant to set/get gravity override mode in an area. See PhysicsServer2D.AreaSpaceOverrideMode for possible values. The default value of this parameter is PhysicsServer2D.AreaSpaceOverrideMode.Disabled.

GravityPointUnitDistance = 4

Constant to set/get the distance at which the gravity strength is equal to the gravity controlled by PhysicsServer2D.AreaParameter.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. The above is true only when the unit distance is a positive number. When the unit distance is set to 0.0, the gravity will be constant regardless of distance. The default value of this parameter is 0.0.

GravityVector = 2

Constant to set/get gravity vector/center in an area. The default value of this parameter is Vector2(0, -1).

LinearDamp = 6

Constant to set/get the linear damping factor of an area. The default value of this parameter is 0.1.

LinearDampOverrideMode = 5

Constant to set/get linear damping override mode in an area. See PhysicsServer2D.AreaSpaceOverrideMode for possible values. The default value of this parameter is PhysicsServer2D.AreaSpaceOverrideMode.Disabled.

Priority = 9

Constant to set/get the priority (order of processing) of an area. The default value of this parameter is 0.

PhysicsServer2D.AreaSpaceOverrideMode

ValueDescription
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

ValueDescription
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

ValueDescription
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

ValueDescription
AngularDamp = 9

Constant to set/get a body's angular damping factor. The default value of this parameter is 0.0.

AngularDampMode = 7

Constant to set/get a body's angular damping mode. See PhysicsServer2D.BodyDampMode for possible values. The default value of this parameter is PhysicsServer2D.BodyDampMode.Combine.

Bounce = 0

Constant to set/get a body's bounce factor. The default value of this parameter is 0.0.

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 Vector2(0, 0). If this parameter is never set explicitly, then it is recalculated based on the body's shapes when setting the parameter PhysicsServer2D.BodyParameter.Mass or when calling PhysicsServer2D.BodySetSpace.

Friction = 1

Constant to set/get a body's friction. The default value of this parameter is 1.0.

GravityScale = 5

Constant to set/get a body's gravity multiplier. The default value of this parameter is 1.0.

Inertia = 3

Constant to set/get a body's inertia. The default value of this parameter is 0.0. If the body's inertia is set to a value <= 0.0, then the inertia will be recalculated based on the body's shapes, mass, and center of mass.

LinearDamp = 8

Constant to set/get a body's linear damping factor. The default value of this parameter is 0.0.

LinearDampMode = 6

Constant to set/get a body's linear damping mode. See PhysicsServer2D.BodyDampMode for possible values. The default value of this parameter is PhysicsServer2D.BodyDampMode.Combine.

Mass = 2

Constant to set/get a body's mass. The default value of this parameter is 1.0. If the body's mode is set to PhysicsServer2D.BodyMode.Rigid, then setting this parameter will have the following additional effects:

Max = 10

Represents the size of the PhysicsServer2D.BodyParameter enum.

PhysicsServer2D.BodyState

ValueDescription
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

ValueDescription
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

ValueDescription
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 1.5.

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 20.0.

PhysicsServer2D.JointParam

ValueDescription
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 0.0. Note: In Reckfell Physics, this parameter is only used for pin joints and groove joints.

MaxBias = 1

Constant to set/get the maximum speed with which the joint can apply corrections. The default value of this parameter is 3.40282e+38. Note: In Reckfell Physics, this parameter is only used for groove joints.

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 3.40282e+38. Note: In Reckfell Physics, this parameter is only used for groove joints.

PhysicsServer2D.JointType

ValueDescription
DampedSpring = 2

Constant to create damped spring joints.

Groove = 1

Constant to create groove joints.

Max = 3

Represents the size of the PhysicsServer2D.JointType enum.

Pin = 0

Constant to create pin joints.

PhysicsServer2D.PinJointFlag

ValueDescription
AngularLimitEnabled = 0

If true, the pin has a maximum and a minimum rotation.

MotorEnabled = 1

If true, a motor turns the pin.

PhysicsServer2D.PinJointParam

ValueDescription
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 0.0.

PhysicsServer2D.ProcessInfo

ValueDescription
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

ValueDescription
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

ValueDescription
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 ProjectSettings.physics/2d/sleep_threshold_angular.

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 ProjectSettings.physics/2d/sleep_threshold_linear.

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 ProjectSettings.physics/2d/time_before_sleep.

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 ProjectSettings.physics/2d/solver/default_constraint_bias.

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 ProjectSettings.physics/2d/solver/default_contact_bias.

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 ProjectSettings.physics/2d/solver/contact_max_allowed_penetration.

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 ProjectSettings.physics/2d/solver/contact_max_separation.

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 ProjectSettings.physics/2d/solver/contact_recycle_radius.

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 ProjectSettings.physics/2d/solver/solver_iterations.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.