Class reference

PhysicsServer2DExtension

Inherits PhysicsServer2D

Provides virtual methods that can be overridden to create custom PhysicsServer2D implementations.

Description

This class extends PhysicsServer2D by providing additional virtual methods that can be overridden. When these methods are overridden, they will be called instead of the internal methods of the physics server. Intended for use with GDExtension to create custom implementations of PhysicsServer2D.

Methods

void _area_set_pickable(RID area, bool pickable) virtual required

If set to true, allows the area with the given RID to detect mouse inputs when the mouse cursor is hovering on it. Overridable version of PhysicsServer2D's internal area_set_pickable method. Corresponds to CollisionObject2D.input_pickable.

bool _body_collide_shape(RID body, int body_shape, RID shape, Transform2D shape_xform, Vector2 motion, void* results, int result_max, int32_t* result_count) virtual required

Given a body, a shape, and their respective parameters, this method should return true if a collision between the two would occur, with additional details passed in results. Overridable version of PhysicsServer2D's internal shape_collide method. Corresponds to PhysicsDirectSpaceState2D.collide_shape().

float _body_get_contacts_reported_depth_threshold(RID body) virtual required const

Overridable version of PhysicsServer2D's internal body_get_contacts_reported_depth_threshold method. Note: This method is currently unused by Redot's default physics implementation.

void _body_set_contacts_reported_depth_threshold(RID body, float threshold) virtual required

Overridable version of PhysicsServer2D's internal body_set_contacts_reported_depth_threshold method. Note: This method is currently unused by Redot's default physics implementation.

void _body_set_pickable(RID body, bool pickable) virtual required

If set to true, allows the body with the given RID to detect mouse inputs when the mouse cursor is hovering on it. Overridable version of PhysicsServer2D's internal body_set_pickable method. Corresponds to CollisionObject2D.input_pickable.

void _end_sync() virtual required

Called to indicate that the physics server has stopped synchronizing. It is in the loop's iteration/physics phase, and can access physics objects even if running on a separate thread. See also _sync(). Overridable version of PhysicsServer2D's internal end_sync method.

void _flush_queries() virtual required

Called every physics step before _step() to process all remaining queries. Overridable version of PhysicsServer2D's internal flush_queries method.

void _init() virtual required

Called when the main loop is initialized and creates a new instance of this physics server. See also MainLoop._initialize() and _finish(). Overridable version of PhysicsServer2D's internal init method.

bool _is_flushing_queries() virtual required const

Overridable method that should return true when the physics server is processing queries. See also _flush_queries(). Overridable version of PhysicsServer2D's internal is_flushing_queries method.

float _shape_get_custom_solver_bias(RID shape) virtual required const

Should return the custom solver bias of the given shape, which defines how much bodies are forced to separate on contact when this shape is involved. Overridable version of PhysicsServer2D's internal shape_get_custom_solver_bias method. Corresponds to Shape2D.custom_solver_bias.

void _shape_set_custom_solver_bias(RID shape, float bias) virtual required

Should set the custom solver bias for the given shape. It defines how much bodies are forced to separate on contact. Overridable version of PhysicsServer2D's internal shape_get_custom_solver_bias method. Corresponds to Shape2D.custom_solver_bias.

void _space_set_debug_contacts(RID space, int max_contacts) virtual required

Used internally to allow the given space to store contact points, up to max_contacts. This is automatically set for the main World2D's space when SceneTree.debug_collisions_hint is true, or by checking "Visible Collision Shapes" in the editor. Only works in debug builds. Overridable version of PhysicsServer2D's internal space_set_debug_contacts method.

void _step(float step) virtual required

Called every physics step to process the physics simulation. step is the time elapsed since the last physics step, in seconds. It is usually the same as the value returned by Node.get_physics_process_delta_time(). Overridable version of PhysicsServer2D's internal [code skip-lint]step[/code] method.

void _sync() virtual required

Called to indicate that the physics server is synchronizing and cannot access physics states if running on a separate thread. See also _end_sync(). Overridable version of PhysicsServer2D's internal sync method.

Source revision 4f5b14abade2
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.