Server interface for low-level 2D physics access.
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.
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.
Assigns the area to a descendant of [Object], so it can exist in the node tree.
Removes all shapes from an area. It does not delete the shapes, so they can be reassigned later.
Creates an [Area2D]. After creating an [Area2D] with this method, assign it to a space using [method area_set_space] to use the created [Area2D] in the physics world.
Gets the instance ID of the object the area is assigned to.
Returns an area parameter value. See [enum AreaParameter] for a list of available parameters.
Returns the [RID] of the nth shape of an area.
Returns the number of shapes assigned to an area.
Returns the transform matrix of a shape within an area.
Returns the space assigned to the area.
Returns the space override mode for the area.
Returns the transform matrix for an area.
Removes a shape from an area. It does not delete the shape, so it can be reassigned later.
Assigns the area to one or many physics layers.
Sets which physics layers the area will monitor.
Sets the value for an area parameter. See [enum AreaParameter] for a list of available parameters.
Substitutes a given area shape by another. The old shape is selected by its index, the new one by its [RID].
Disables a given shape in an area.
Sets the transform matrix for an area shape.
Assigns a space to the area.
Sets the space override mode for the area. See [enum AreaSpaceOverrideMode] for a list of available modes.
Sets the transform matrix for an area.
Adds a body to the list of bodies exempt from collisions.
Adds a positioned force to the applied force and torque. As with [method body_apply_impulse], 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.
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.
Adds a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates.
Assigns the area to a descendant of [Object], so it can exist in the node tree.
Removes all shapes from a body.
Creates a physics body.
Returns the physics layer or layers a body belongs to.
Returns the physics layer or layers a body can collide with.
Returns the continuous collision detection mode.
Returns the [Physics2DDirectBodyState] of the body. Returns [code]null[/code] if the body is destroyed or removed from the physics space.
Returns the maximum contacts that can be reported. See [method body_set_max_contacts_reported].
Returns the body mode.
Gets the instance ID of the object the area is assigned to.
Returns the value of a body parameter. See [enum BodyParameter] for a list of available parameters.
Returns the [RID] of the nth shape of a body.
Returns the number of shapes assigned to a body.
Returns the metadata of a shape of a body.
Returns the transform matrix of a body shape.
Returns the [RID] of the space assigned to a body.
Returns a body state.
Returns whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
Removes a body from the list of bodies exempt from collisions.
Removes a shape from a body. The shape is not deleted, so it can be reused afterwards.
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.
Sets the physics layer or layers a body belongs to.
Sets the physics layer or layers a body can collide with.
Sets the continuous collision detection mode using one of the [enum 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.
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.
Sets the body mode using one of the [enum BodyMode] constants.
Sets whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]).
Sets a body parameter. See [enum BodyParameter] for a list of available parameters.
Substitutes a given body shape by another. The old shape is selected by its index, the new one by its [RID].
Enables one way collision on body if [code]enable[/code] is [code]true[/code].
Disables shape in body if [code]disable[/code] is [code]true[/code].
Sets metadata of a shape within a body. This metadata is different from [method Object.set_meta], and can be retrieved on shape queries.
Sets the transform matrix for a body shape.
Assigns a space to the body (see [method space_create]).
Sets a body state using one of the [enum BodyState] constants.
Note that the method doesn't take effect immediately. The state will change on the next physics frame.
Returns [code]true[/code] 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.
Creates a damped spring joint between two bodies. If not specified, the second body is assumed to be the joint itself.
Returns the value of a damped spring joint parameter.
Sets a damped spring joint parameter. See [enum DampedStringParam] for a list of available parameters.
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.
Returns information about the current state of the 2D physics engine. See [enum ProcessInfo] for a list of available states.
Creates a groove joint between two bodies. If not specified, the bodies are assumed to be the joint itself.
Returns the value of a joint parameter.
Returns a joint's type (see [enum JointType]).
Sets a joint parameter. See [enum JointParam] for a list of available parameters.
Creates a pin joint between two bodies. If not specified, the second body is assumed to be the joint itself.
Activates or deactivates the 2D physics engine.
Sets the amount of iterations for calculating velocities of colliding bodies. The greater the amount of iterations, the more accurate the collisions will be. However, a greater amount of iterations requires more CPU power, which can decrease performance. The default value is [code]8[/code].
Returns the shape data.
Returns a shape's type (see [enum ShapeType]).
Sets the shape data that defines its shape and size. The data to be passed depends on the kind of shape created [method shape_get_type].
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 [method area_set_space], or to a body with [method body_set_space].
Returns the state of a space, a [Physics2DDirectSpaceState]. This object can be used to make collision/intersection queries.
Returns the value of a space parameter.
Returns whether the space is active.
Marks a space as active. It will not have an effect, unless it is assigned to an area or body.
Sets the value for a space parameter. See [enum SpaceParameter] for a list of available parameters.
Constant to set/get the maximum distance a pair of bodies has to move before their collision status has to be recalculated.
Constant to set/get the maximum distance a shape can be from another before they are considered separated.
Constant to set/get the maximum distance a shape can penetrate another shape before it is considered a collision.
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.
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.
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.
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.
This is the constant for creating line shapes. A line shape is an infinite line with an origin point, and a normal. Thus, it can be used for front/behind checks.
This is the constant for creating segment shapes. A segment shape is a line from a point A to a point B. It can be checked for intersections.
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.
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.
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.
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. Unlike the [member CollisionPolygon2D.polygon] property, polygons modified with [method shape_set_data] do not verify that the points supplied form is a convex polygon.
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.
This constant is used internally by the engine. Any attempt to create this kind of shape results in an error.
Constant to set/get gravity strength in an area.
Constant to set/get gravity vector/center in an area.
Constant to set/get whether the gravity vector of an area is a direction, or a center point.
Constant to set/get the falloff factor for point gravity of an area. The greater this value is, the faster the strength of gravity decreases with the square of distance.
This constant was used to set/get the falloff factor for point gravity. It has been superseded by [constant AREA_PARAM_GRAVITY_DISTANCE_SCALE].
Constant to set/get the linear dampening factor of an area.
Constant to set/get the angular dampening factor of an area.
Constant to set/get the priority (order of processing) of an area.
This area does not affect gravity/damp. These are generally areas that exist only to detect collisions, and objects entering or exiting them.
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.
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.
This area replaces any gravity/damp, even the default one, and stops taking into account the rest of the areas.
This area replaces any gravity/damp calculated so far, but keeps calculating the rest of the areas, down to the default one.
Constant for static bodies.
Constant for kinematic bodies.
Constant for rigid bodies.
Constant for rigid bodies in character mode. In this mode, a body can not rotate, and only its linear velocity is affected by physics.
Constant to set/get a body's bounce factor.
Constant to set/get a body's friction.
Constant to set/get a body's mass.
Constant to set/get a body's inertia.
Constant to set/get a body's gravity multiplier.
Constant to set/get a body's linear dampening factor.
Constant to set/get a body's angular dampening factor.
Represents the size of the [enum BodyParameter] enum.
Constant to set/get the current transform matrix of the body.
Constant to set/get the current linear velocity of the body.
Constant to set/get the current angular velocity of the body.
Constant to sleep/wake up a body, or to get whether it is sleeping.
Constant to set/get whether the body can sleep.
Constant to create pin joints.
Constant to create groove joints.
Constant to create damped spring joints.
Sets the resting length of the spring joint. The joint will always try to go to back this length when pulled apart.
Sets the stiffness of the spring joint. The joint applies a force equal to the stiffness times the distance from its resting length.
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).
Disables continuous collision detection. This is the fastest way to detect body collisions, but can miss small, fast-moving objects.
Enables continuous collision detection by raycasting. It is faster than shapecasting, but less precise.
Enables continuous collision detection by shapecasting. It is the slowest CCD method, and the most precise.
The value of the first parameter and area callback function receives, when an object enters one of its shapes.
The value of the first parameter and area callback function receives, when an object exits one of its shapes.
Constant to get the number of objects that are not sleeping.
Constant to get the number of possible collisions.
Constant to get the number of space regions where a collision could occur.