Click or drag to resize

Physics2DServer Methods

The Physics2DServer type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAreaAddShape

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.

Public methodStatic memberAreaAttachCanvasInstanceId
Public methodStatic memberAreaAttachObjectInstanceId

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

Public methodStatic memberAreaClearShapes

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

Public methodStatic memberAreaCreate

Creates an Area2D. After creating an Area2D with this method, assign it to a space using AreaSetSpace(RID, RID) to use the created Area2D in the physics world.

Public methodStatic memberAreaGetCanvasInstanceId
Public methodStatic memberAreaGetObjectInstanceId

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

Public methodStatic memberAreaGetParam

Returns an area parameter value. See Physics2DServerAreaParameter for a list of available parameters.

Public methodStatic memberAreaGetShape

Returns the RID of the nth shape of an area.

Public methodStatic memberAreaGetShapeCount

Returns the number of shapes assigned to an area.

Public methodStatic memberAreaGetShapeTransform

Returns the transform matrix of a shape within an area.

Public methodStatic memberAreaGetSpace

Returns the space assigned to the area.

Public methodStatic memberAreaGetSpaceOverrideMode

Returns the space override mode for the area.

Public methodStatic memberAreaGetTransform

Returns the transform matrix for an area.

Public methodStatic memberAreaRemoveShape

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

Public methodStatic memberAreaSetAreaMonitorCallback
Public methodStatic memberAreaSetCollisionLayer

Assigns the area to one or many physics layers.

Public methodStatic memberAreaSetCollisionMask

Sets which physics layers the area will monitor.

Public methodStatic memberAreaSetMonitorable
Public methodStatic memberAreaSetMonitorCallback

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

Public methodStatic memberAreaSetParam

Sets the value for an area parameter. See Physics2DServerAreaParameter for a list of available parameters.

Public methodStatic memberAreaSetShape

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

Public methodStatic memberAreaSetShapeDisabled

Disables a given shape in an area.

Public methodStatic memberAreaSetShapeTransform

Sets the transform matrix for an area shape.

Public methodStatic memberAreaSetSpace

Assigns a space to the area.

Public methodStatic memberAreaSetSpaceOverrideMode

Sets the space override mode for the area. See Physics2DServerAreaSpaceOverrideMode for a list of available modes.

Public methodStatic memberAreaSetTransform

Sets the transform matrix for an area.

Public methodStatic memberBodyAddCentralForce
Public methodStatic memberBodyAddCollisionException

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

Public methodStatic memberBodyAddForce

Adds a positioned force to the applied force and torque. As with BodyApplyImpulse(RID, Vector2, Vector2), 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.

Public methodStatic memberBodyAddShape

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.

Public methodStatic memberBodyAddTorque
Public methodStatic memberBodyApplyCentralImpulse
Public methodStatic memberBodyApplyImpulse

Adds a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates.

Public methodStatic memberBodyApplyTorqueImpulse
Public methodStatic memberBodyAttachCanvasInstanceId
Public methodStatic memberBodyAttachObjectInstanceId

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

Public methodStatic memberBodyClearShapes

Removes all shapes from a body.

Public methodStatic memberBodyCreate

Creates a physics body.

Public methodStatic memberBodyGetCanvasInstanceId
Public methodStatic memberBodyGetCollisionLayer

Returns the physics layer or layers a body belongs to.

Public methodStatic memberBodyGetCollisionMask

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

Public methodStatic memberBodyGetContinuousCollisionDetectionMode

Returns the continuous collision detection mode.

Public methodStatic memberBodyGetDirectState

Returns the Physics2DDirectBodyState of the body.

Public methodStatic memberBodyGetMaxContactsReported

Returns the maximum contacts that can be reported. See BodySetMaxContactsReported(RID, Int32).

Public methodStatic memberBodyGetMode

Returns the body mode.

Public methodStatic memberBodyGetObjectInstanceId

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

Public methodStatic memberBodyGetParam

Returns the value of a body parameter. See Physics2DServerBodyParameter for a list of available parameters.

Public methodStatic memberBodyGetShape

Returns the RID of the nth shape of a body.

Public methodStatic memberBodyGetShapeCount

Returns the number of shapes assigned to a body.

Public methodStatic memberBodyGetShapeMetadata

Returns the metadata of a shape of a body.

Public methodStatic memberBodyGetShapeTransform

Returns the transform matrix of a body shape.

Public methodStatic memberBodyGetSpace

Returns the RID of the space assigned to a body.

Public methodStatic memberBodyGetState

Returns a body state.

Public methodStatic memberBodyIsOmittingForceIntegration

Returns whether a body uses a callback function to calculate its own physics (see BodySetForceIntegrationCallback(RID, Object, String, Object)).

Public methodStatic memberBodyRemoveCollisionException

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

Public methodStatic memberBodyRemoveShape

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

Public methodStatic memberBodySetAxisVelocity

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.

Public methodStatic memberBodySetCollisionLayer

Sets the physics layer or layers a body belongs to.

Public methodStatic memberBodySetCollisionMask

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

Public methodStatic memberBodySetContinuousCollisionDetectionMode

Sets the continuous collision detection mode using one of the Physics2DServerCCDMode constants.

Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided.

Public methodStatic memberBodySetForceIntegrationCallback

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

Public methodStatic memberBodySetMaxContactsReported

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.

Public methodStatic memberBodySetMode
Public methodStatic memberBodySetOmitForceIntegration

Sets whether a body uses a callback function to calculate its own physics (see BodySetForceIntegrationCallback(RID, Object, String, Object)).

Public methodStatic memberBodySetParam
Public methodStatic memberBodySetShape

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

Public methodStatic memberBodySetShapeAsOneWayCollision

Enables one way collision on body if enable is true.

Public methodStatic memberBodySetShapeDisabled

Disables shape in body if disable is true.

Public methodStatic memberBodySetShapeMetadata

Sets metadata of a shape within a body. This metadata is different from SetMeta(String, Object), and can be retrieved on shape queries.

Public methodStatic memberBodySetShapeTransform

Sets the transform matrix for a body shape.

Public methodStatic memberBodySetSpace
Public methodStatic memberBodySetState

Sets a body state using one of the Physics2DServerBodyState constants.

Note that the method doesn't take effect immediately. The state will change on the next physics frame.

Public methodStatic memberBodyTestMotion

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.

Public methodStatic memberCapsuleShapeCreate
Public methodStatic memberCircleShapeCreate
Public methodStatic memberConcavePolygonShapeCreate
Public methodStatic memberConvexPolygonShapeCreate
Public methodStatic memberDampedSpringJointCreate

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

Public methodStatic memberDampedStringJointGetParam

Returns the value of a damped spring joint parameter.

Public methodStatic memberDampedStringJointSetParam

Sets a damped spring joint parameter. See Physics2DServerDampedStringParam for a list of available parameters.

Public methodStatic memberFreeRid

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.

Public methodStatic memberGetProcessInfo

Returns information about the current state of the 2D physics engine. See Physics2DServerProcessInfo for a list of available states.

Public methodStatic memberGrooveJointCreate

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

Public methodStatic memberJointGetParam

Returns the value of a joint parameter.

Public methodStatic memberJointGetType
Public methodStatic memberJointSetParam
Public methodStatic memberLineShapeCreate
Public methodStatic memberPinJointCreate

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

Public methodStatic memberRayShapeCreate
Public methodStatic memberRectangleShapeCreate
Public methodStatic memberSegmentShapeCreate
Public methodStatic memberSetActive

Activates or deactivates the 2D physics engine.

Public methodStatic memberShapeGetData

Returns the shape data.

Public methodStatic memberShapeGetType
Public methodStatic memberShapeSetData

Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created ShapeGetType(RID).

Public methodStatic memberSpaceCreate

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(RID, RID), or to a body with BodySetSpace(RID, RID).

Public methodStatic memberSpaceGetDirectState

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

Public methodStatic memberSpaceGetParam

Returns the value of a space parameter.

Public methodStatic memberSpaceIsActive

Returns whether the space is active.

Public methodStatic memberSpaceSetActive

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

Public methodStatic memberSpaceSetParam

Sets the value for a space parameter. See Physics2DServerSpaceParameter for a list of available parameters.

Top
See Also