Struct Physics2DServerSingleton

Server interface for low-level 2D physics access.

struct Physics2DServerSingleton ;

Physics2DServer is the server responsible for all 2D physics. It can create many kinds of physics objects, but does not insert them on the node tree.

Methods

NameDescription
areaAddShape Adds a shape to the area, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.
areaAttachCanvasInstanceId
areaAttachObjectInstanceId Assigns the area to a descendant of GodotObject, so it can exist in the node tree.
areaClearShapes Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.
areaCreate Creates an Area2D.
areaGetCanvasInstanceId
areaGetObjectInstanceId Gets the instance ID of the object the area is assigned to.
areaGetParam Returns an area parameter value. See areaparameter for a list of available parameters.
areaGetShape Returns the RID of the nth shape of an area.
areaGetShapeCount Returns the number of shapes assigned to an area.
areaGetShapeTransform Returns the transform matrix of a shape within an area.
areaGetSpace Returns the space assigned to the area.
areaGetSpaceOverrideMode Returns the space override mode for the area.
areaGetTransform Returns the transform matrix for an area.
areaRemoveShape Removes a shape from an area. It does not delete the shape, so it can be reassigned later.
areaSetAreaMonitorCallback
areaSetCollisionLayer Assigns the area to one or many physics layers.
areaSetCollisionMask Sets which physics layers the area will monitor.
areaSetMonitorable
areaSetMonitorCallback Sets the function to call when any body/area enters or exits the area. This callback will be called for any object interacting with the area, and takes five parameters: 1: constant AREA_BODY_ADDED or constant AREA_BODY_REMOVED, depending on whether the object entered or exited the area. 2: RID of the object that entered/exited the area. 3: Instance ID of the object that entered/exited the area. 4: The shape index of the object that entered/exited the area. 5: The shape index of the area where the object entered/exited.
areaSetParam Sets the value for an area parameter. See areaparameter for a list of available parameters.
areaSetShape Substitutes a given area shape by another. The old shape is selected by its index, the new one by its RID.
areaSetShapeDisabled Disables a given shape in an area.
areaSetShapeTransform Sets the transform matrix for an area shape.
areaSetSpace Assigns a space to the area.
areaSetSpaceOverrideMode Sets the space override mode for the area. See areaspaceoverridemode for a list of available modes.
areaSetTransform Sets the transform matrix for an area.
bodyAddCentralForce
bodyAddCollisionException Adds a body to the list of bodies exempt from collisions.
bodyAddForce Adds a positioned force to the applied force and torque. As with bodyApplyImpulse, both the force and the offset from the body origin are in global coordinates. A force differs from an impulse in that, while the two are forces, the impulse clears itself after being applied.
bodyAddShape Adds a shape to the body, along with a transform matrix. Shapes are usually referenced by their index, so you should track which shape has a given index.
bodyAddTorque
bodyApplyCentralImpulse
bodyApplyImpulse Adds a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates.
bodyApplyTorqueImpulse
bodyAttachCanvasInstanceId
bodyAttachObjectInstanceId Assigns the area to a descendant of GodotObject, so it can exist in the node tree.
bodyClearShapes Removes all shapes from a body.
bodyCreate Creates a physics body.
bodyGetCanvasInstanceId
bodyGetCollisionLayer Returns the physics layer or layers a body belongs to.
bodyGetCollisionMask Returns the physics layer or layers a body can collide with.
bodyGetContinuousCollisionDetectionMode Returns the continuous collision detection mode.
bodyGetDirectState Returns the Physics2DDirectBodyState of the body.
bodyGetMaxContactsReported Returns the maximum contacts that can be reported. See bodySetMaxContactsReported.
bodyGetMode Returns the body mode.
bodyGetObjectInstanceId Gets the instance ID of the object the area is assigned to.
bodyGetParam Returns the value of a body parameter. See bodyparameter for a list of available parameters.
bodyGetShape Returns the RID of the nth shape of a body.
bodyGetShapeCount Returns the number of shapes assigned to a body.
bodyGetShapeMetadata Returns the metadata of a shape of a body.
bodyGetShapeTransform Returns the transform matrix of a body shape.
bodyGetSpace Returns the RID of the space assigned to a body.
bodyGetState Returns a body state.
bodyIsOmittingForceIntegration Returns whether a body uses a callback function to calculate its own physics (see bodySetForceIntegrationCallback).
bodyRemoveCollisionException Removes a body from the list of bodies exempt from collisions.
bodyRemoveShape Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.
bodySetAxisVelocity Sets an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.
bodySetCollisionLayer Sets the physics layer or layers a body belongs to.
bodySetCollisionMask Sets the physics layer or layers a body can collide with.
bodySetContinuousCollisionDetectionMode Sets the continuous collision detection mode using one of the ccdmode constants. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.
bodySetForceIntegrationCallback Sets the function used to calculate physics for an object, if that object allows it (see bodySetOmitForceIntegration).
bodySetMaxContactsReported Sets the maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
bodySetMode Sets the body mode using one of the bodymode constants.
bodySetOmitForceIntegration Sets whether a body uses a callback function to calculate its own physics (see bodySetForceIntegrationCallback).
bodySetParam Sets a body parameter. See bodyparameter for a list of available parameters.
bodySetShape Substitutes a given body shape by another. The old shape is selected by its index, the new one by its RID.
bodySetShapeAsOneWayCollision Enables one way collision on body if enable is true.
bodySetShapeDisabled Disables shape in body if disable is true.
bodySetShapeMetadata Sets metadata of a shape within a body. This metadata is different from GodotObject.setMeta, and can be retrieved on shape queries.
bodySetShapeTransform Sets the transform matrix for a body shape.
bodySetSpace Assigns a space to the body (see spaceCreate).
bodySetState Sets a body state using one of the bodystate constants.
bodyTestMotion Returns true if a collision would result from moving in the given direction from a given point in space. Margin increases the size of the shapes involved in the collision detection. Physics2DTestMotionResult can be passed to return additional information in.
capsuleShapeCreate
circleShapeCreate
concavePolygonShapeCreate
convexPolygonShapeCreate
dampedSpringJointCreate Creates a damped spring joint between two bodies. If not specified, the second body is assumed to be the joint itself.
dampedStringJointGetParam Returns the value of a damped spring joint parameter.
dampedStringJointSetParam Sets a damped spring joint parameter. See dampedstringparam for a list of available parameters.
freeRid Destroys any of the objects created by Physics2DServer. If the RID passed is not one of the objects that can be created by Physics2DServer, an error will be sent to the console.
getProcessInfo Returns information about the current state of the 2D physics engine. See processinfo for a list of available states.
grooveJointCreate Creates a groove joint between two bodies. If not specified, the bodies are assumed to be the joint itself.
jointGetParam Returns the value of a joint parameter.
jointGetType Returns a joint's type (see jointtype).
jointSetParam Sets a joint parameter. See jointparam for a list of available parameters.
lineShapeCreate
pinJointCreate Creates a pin joint between two bodies. If not specified, the second body is assumed to be the joint itself.
rayShapeCreate
rectangleShapeCreate
segmentShapeCreate
setActive Activates or deactivates the 2D physics engine.
shapeGetData Returns the shape data.
shapeGetType Returns a shape's type (see shapetype).
shapeSetData Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created shapeGetType.
spaceCreate Creates a space. A space is a collection of parameters for the physics engine that can be assigned to an area or a body. It can be assigned to an area with areaSetSpace, or to a body with bodySetSpace.
spaceGetDirectState Returns the state of a space, a Physics2DDirectSpaceState. This object can be used to make collision/intersection queries.
spaceGetParam Returns the value of a space parameter.
spaceIsActive Returns whether the space is active.
spaceSetActive Marks a space as active. It will not have an effect, unless it is assigned to an area or body.
spaceSetParam Sets the value for a space parameter. See spaceparameter for a list of available parameters.

Enums

NameDescription
AreaBodyStatus
AreaParameter
AreaSpaceOverrideMode
BodyMode
BodyParameter
BodyState
CCDMode
Constants
DampedStringParam
JointParam
JointType
ProcessInfo
ShapeType
SpaceParameter