Physics2DServerSingleton

Physics 2D Server.

Physics 2D Server 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.

@GodotBaseClass
struct Physics2DServerSingleton {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

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

Functions

areaAddShape
void areaAddShape(RID area, RID shape, Transform2D transform)

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.

areaAttachObjectInstanceId
void areaAttachObjectInstanceId(RID area, long id)

Assigns the area to a descendant of GodotObject, so it can exist in the node tree.

areaClearShapes
void areaClearShapes(RID area)

Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.

areaCreate
RID areaCreate()

Creates an Area2D.

areaGetObjectInstanceId
long areaGetObjectInstanceId(RID area)

Gets the instance ID of the object the area is assigned to.

areaGetParam
Variant areaGetParam(RID area, long param)

Returns an area parameter value. A list of available parameters is on the AREA_PARAM_* constants.

areaGetShape
RID areaGetShape(RID area, long shape_idx)

Returns the RID of the nth shape of an area.

areaGetShapeCount
long areaGetShapeCount(RID area)

Returns the number of shapes assigned to an area.

areaGetShapeTransform
Transform2D areaGetShapeTransform(RID area, long shape_idx)

Returns the transform matrix of a shape within an area.

areaGetSpace
RID areaGetSpace(RID area)

Returns the space assigned to the area.

areaGetSpaceOverrideMode
Physics2DServer.AreaSpaceOverrideMode areaGetSpaceOverrideMode(RID area)

Returns the space override mode for the area.

areaGetTransform
Transform2D areaGetTransform(RID area)

Returns the transform matrix for an area.

areaRemoveShape
void areaRemoveShape(RID area, long shape_idx)

Removes a shape from an area. It does not delete the shape, so it can be reassigned later.

areaSetAreaMonitorCallback
void areaSetAreaMonitorCallback(RID area, GodotObject receiver, StringArg2 method)
areaSetCollisionLayer
void areaSetCollisionLayer(RID area, long layer)

Assigns the area to one or many physics layers.

areaSetCollisionMask
void areaSetCollisionMask(RID area, long mask)

Sets which physics layers the area will monitor.

areaSetMonitorCallback
void areaSetMonitorCallback(RID area, GodotObject receiver, StringArg2 method)

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: AREA_BODY_ADDED or 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.

areaSetMonitorable
void areaSetMonitorable(RID area, bool monitorable)
areaSetParam
void areaSetParam(RID area, long param, VariantArg2 value)

Sets the value for an area parameter. A list of available parameters is on the AREA_PARAM_* constants.

areaSetShape
void areaSetShape(RID area, long shape_idx, RID shape)

Substitutes a given area shape by another. The old shape is selected by its index, the new one by its RID.

areaSetShapeDisabled
void areaSetShapeDisabled(RID area, long shape_idx, bool disable)

Disables a given shape in an area.

areaSetShapeTransform
void areaSetShapeTransform(RID area, long shape_idx, Transform2D transform)

Sets the transform matrix for an area shape.

areaSetSpace
void areaSetSpace(RID area, RID space)

Assigns a space to the area.

areaSetSpaceOverrideMode
void areaSetSpaceOverrideMode(RID area, long mode)

Sets the space override mode for the area. The modes are described in the constants AREA_SPACE_OVERRIDE_*.

areaSetTransform
void areaSetTransform(RID area, Transform2D transform)

Sets the transform matrix for an area.

bodyAddCentralForce
void bodyAddCentralForce(RID _body, Vector2 force)
bodyAddCollisionException
void bodyAddCollisionException(RID _body, RID excepted_body)

Adds a body to the list of bodies exempt from collisions.

bodyAddForce
void bodyAddForce(RID _body, Vector2 offset, Vector2 force)

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
void bodyAddShape(RID _body, RID shape, Transform2D transform)

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
void bodyAddTorque(RID _body, double torque)
bodyApplyCentralImpulse
void bodyApplyCentralImpulse(RID _body, Vector2 impulse)
bodyApplyImpulse
void bodyApplyImpulse(RID _body, Vector2 position, Vector2 impulse)

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
void bodyApplyTorqueImpulse(RID _body, double impulse)
bodyAttachObjectInstanceId
void bodyAttachObjectInstanceId(RID _body, long id)

Assigns the area to a descendant of GodotObject, so it can exist in the node tree.

bodyClearShapes
void bodyClearShapes(RID _body)

Removes all shapes from a body.

bodyCreate
RID bodyCreate()

Creates a physics body. The first parameter can be any value from constants BODY_MODE*, for the type of body created. Additionally, the body can be created in sleeping state to save processing time.

bodyGetCollisionLayer
long bodyGetCollisionLayer(RID _body)

Returns the physics layer or layers a body belongs to.

bodyGetCollisionMask
long bodyGetCollisionMask(RID _body)

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

bodyGetContinuousCollisionDetectionMode
Physics2DServer.CCDMode bodyGetContinuousCollisionDetectionMode(RID _body)

Returns the continuous collision detection mode.

bodyGetDirectState
Physics2DDirectBodyState bodyGetDirectState(RID _body)

Returns the Physics2DDirectBodyState of the body.

bodyGetMaxContactsReported
long bodyGetMaxContactsReported(RID _body)

Returns the maximum contacts that can be reported. See bodySetMaxContactsReported.

bodyGetMode
Physics2DServer.BodyMode bodyGetMode(RID _body)

Returns the body mode.

bodyGetObjectInstanceId
long bodyGetObjectInstanceId(RID _body)

Gets the instance ID of the object the area is assigned to.

bodyGetParam
double bodyGetParam(RID _body, long param)

Returns the value of a body parameter. A list of available parameters is on the BODY_PARAM_* constants.

bodyGetShape
RID bodyGetShape(RID _body, long shape_idx)

Returns the RID of the nth shape of a body.

bodyGetShapeCount
long bodyGetShapeCount(RID _body)

Returns the number of shapes assigned to a body.

bodyGetShapeMetadata
Variant bodyGetShapeMetadata(RID _body, long shape_idx)

Returns the metadata of a shape of a body.

bodyGetShapeTransform
Transform2D bodyGetShapeTransform(RID _body, long shape_idx)

Returns the transform matrix of a body shape.

bodyGetSpace
RID bodyGetSpace(RID _body)

Returns the RID of the space assigned to a body.

bodyGetState
Variant bodyGetState(RID _body, long state)

Returns a body state.

bodyIsOmittingForceIntegration
bool bodyIsOmittingForceIntegration(RID _body)

Returns whether a body uses a callback function to calculate its own physics (see bodySetForceIntegrationCallback).

bodyRemoveCollisionException
void bodyRemoveCollisionException(RID _body, RID excepted_body)

Removes a body from the list of bodies exempt from collisions.

bodyRemoveShape
void bodyRemoveShape(RID _body, long shape_idx)

Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.

bodySetAxisVelocity
void bodySetAxisVelocity(RID _body, Vector2 axis_velocity)

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
void bodySetCollisionLayer(RID _body, long layer)

Sets the physics layer or layers a body belongs to.

bodySetCollisionMask
void bodySetCollisionMask(RID _body, long mask)

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

bodySetContinuousCollisionDetectionMode
void bodySetContinuousCollisionDetectionMode(RID _body, long mode)

Sets the continuous collision detection mode from any of the CCD_MODE_* 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
void bodySetForceIntegrationCallback(RID _body, GodotObject receiver, StringArg2 method, VariantArg3 userdata)

Sets the function used to calculate physics for an object, if that object allows it (see bodySetOmitForceIntegration).

bodySetMaxContactsReported
void bodySetMaxContactsReported(RID _body, long amount)

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
void bodySetMode(RID _body, long mode)

Sets the body mode, from one of the constants BODY_MODE*.

bodySetOmitForceIntegration
void bodySetOmitForceIntegration(RID _body, bool enable)

Sets whether a body uses a callback function to calculate its own physics (see bodySetForceIntegrationCallback).

bodySetParam
void bodySetParam(RID _body, long param, double value)

Sets a body parameter. A list of available parameters is on the BODY_PARAM_* constants.

bodySetShape
void bodySetShape(RID _body, long shape_idx, RID shape)

Substitutes a given body shape by another. The old shape is selected by its index, the new one by its RID.

bodySetShapeAsOneWayCollision
void bodySetShapeAsOneWayCollision(RID _body, long shape_idx, bool enable)

Enables one way collision on body if enable is true.

bodySetShapeDisabled
void bodySetShapeDisabled(RID _body, long shape_idx, bool disable)

Disables shape in body if disable is true.

bodySetShapeMetadata
void bodySetShapeMetadata(RID _body, long shape_idx, VariantArg2 metadata)

Sets metadata of a shape within a body. This metadata is different from GodotObject.setMeta, and can be retrieved on shape queries.

bodySetShapeTransform
void bodySetShapeTransform(RID _body, long shape_idx, Transform2D transform)

Sets the transform matrix for a body shape.

bodySetSpace
void bodySetSpace(RID _body, RID space)

Assigns a space to the body (see spaceCreate).

bodySetState
void bodySetState(RID _body, long state, VariantArg2 value)

Sets a body state (see BODY_STATE* constants).

bodyTestMotion
bool bodyTestMotion(RID _body, Transform2D from, Vector2 motion, bool infinite_inertia, double margin, Physics2DTestMotionResult result)

Returns whether a body can move from a given point in a given direction. Apart from the boolean return value, a Physics2DTestMotionResult can be passed to return additional information in.

capsuleShapeCreate
RID capsuleShapeCreate()
circleShapeCreate
RID circleShapeCreate()
concavePolygonShapeCreate
RID concavePolygonShapeCreate()
convexPolygonShapeCreate
RID convexPolygonShapeCreate()
dampedSpringJointCreate
RID dampedSpringJointCreate(Vector2 anchor_a, Vector2 anchor_b, RID body_a, RID body_b)

Creates a damped spring joint between two bodies. If not specified, the second body is assumed to be the joint itself.

dampedStringJointGetParam
double dampedStringJointGetParam(RID joint, long param)

Returns the value of a damped spring joint parameter.

dampedStringJointSetParam
void dampedStringJointSetParam(RID joint, long param, double value)

Sets a damped spring joint parameter. Parameters are explained in the DAMPED_STRING* constants.

freeRid
void freeRid(RID rid)

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
long getProcessInfo(long process_info)

Returns information about the current state of the 2D physics engine. The states are listed under the INFO_* constants.

grooveJointCreate
RID grooveJointCreate(Vector2 groove1_a, Vector2 groove2_a, Vector2 anchor_b, RID body_a, RID body_b)

Creates a groove joint between two bodies. If not specified, the bodyies are assumed to be the joint itself.

jointGetParam
double jointGetParam(RID joint, long param)

Returns the value of a joint parameter.

jointGetType
Physics2DServer.JointType jointGetType(RID joint)

Returns the type of a joint (see JOINT_* constants).

jointSetParam
void jointSetParam(RID joint, long param, double value)

Sets a joint parameter. Parameters are explained in the JOINT_PARAM* constants.

lineShapeCreate
RID lineShapeCreate()
opAssign
Physics2DServerSingleton opAssign(T n)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Physics2DServerSingleton other)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(typeof(null) n)
Undocumented in source. Be warned that the author may not have intended to support it.
pinJointCreate
RID pinJointCreate(Vector2 anchor, RID body_a, RID body_b)

Creates a pin joint between two bodies. If not specified, the second body is assumed to be the joint itself.

rayShapeCreate
RID rayShapeCreate()
rectangleShapeCreate
RID rectangleShapeCreate()
segmentShapeCreate
RID segmentShapeCreate()
setActive
void setActive(bool active)

Activates or deactivates the 2D physics engine.

shapeGetData
Variant shapeGetData(RID shape)

Returns the shape data.

shapeGetType
Physics2DServer.ShapeType shapeGetType(RID shape)

Returns the type of shape (see SHAPE_* constants).

shapeSetData
void shapeSetData(RID shape, VariantArg1 data)

Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created shapeGetType.

spaceCreate
RID 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
Physics2DDirectSpaceState spaceGetDirectState(RID space)

Returns the state of a space, a Physics2DDirectSpaceState. This object can be used to make collision/intersection queries.

spaceGetParam
double spaceGetParam(RID space, long param)

Returns the value of a space parameter.

spaceIsActive
bool spaceIsActive(RID space)

Returns whether the space is active.

spaceSetActive
void spaceSetActive(RID space, bool active)

Marks a space as active. It will not have an effect, unless it is assigned to an area or body.

spaceSetParam
void spaceSetParam(RID space, long param, double value)

Sets the value for a space parameter. A list of available parameters is on the SPACE_PARAM_* constants.

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Static functions

_new
Physics2DServerSingleton _new()
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

_classBinding
struct _classBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
ToRef as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta