PhysicsWorld Class

Scoped wrapper around a Box2D world. One instance per scene, registered as scoped in DI. Users work entirely in pixel coordinates; the Brine2D.Physics.PhysicsWorld.PixelsPerMeter ratio is applied once via Box2D.NET.Bindings.B2.SetLengthUnitsPerMeter(System.Single) so Box2D operates in pixel space internally. Because Box2D.NET.Bindings.B2.SetLengthUnitsPerMeter(System.Single) is a process-wide global, the value is locked to the first instance and released automatically when the last world is disposed.

public sealed class PhysicsWorld : System.IDisposable

Inheritance System.Object → PhysicsWorld

Implements System.IDisposable

Constructors
PhysicsWorld() Initializes a new PhysicsWorld with default settings.
Properties
Gravity Current world gravity in pixels per second squared.
IsPaused Whether the world is currently paused. When true, Brine2D.Physics.PhysicsWorld.Step(System.Single) is a no-op and no simulation or event dispatch occurs. In-flight contact state is preserved.
IsValid true when the world has not been disposed and the underlying Box2D world handle is still valid. Safe to call at any time — never throws.
SubStepCount Number of Box2D sub-steps per fixed-update tick. Higher values improve simulation accuracy for fast-moving bodies at the cost of CPU time. Default is 4.
Methods
ApplyExplosionImpulse(Vector2, float, float, float, Nullable<PhysicsQueryFilter>) Applies an outward radial impulse to all dynamic bodies within radius pixels of center. Impulse magnitude falls off linearly with distance from center, reaching zero at the edge of the radius.
FlushPendingIgnoredPairs(PhysicsBodyComponent) Checks all pending deferred IgnoreCollision(PhysicsBodyComponent, PhysicsBodyComponent) entries and promotes any pair where both bodies are now live. Called by Box2DPhysicsSystem after a body is created or rebuilt.
GetAllBodies() Returns all currently simulated PhysicsBodyComponent instances tracked by the physics system. Returns an empty sequence if the physics system has not been initialized yet.
GetAllJoints(List<JointComponent>) Fills results with every JointComponent currently registered in the world, deduplicated (joints connecting two bodies appear only once). Clears results before writing.
GetContacts(PhysicsBodyComponent, Span<ContactPair>) Reads the live contact manifolds for body directly from Box2D and writes them into results. Returns 0 if the body is not live, has no active contacts, or results is empty.
GetContacts(PhysicsBodyComponent, Span<ContactPair>, bool) Reads the live contact manifolds for body directly from Box2D and writes them into results. Returns 0 if the body is not live, has no active contacts, or results is empty.
GetContactsAll(PhysicsBodyComponent, List<ContactPair>) Reads the live contact manifolds for body directly from Box2D and adds them to results. Clears results before writing. Returns immediately if the body is not live or has no active contacts.
GetCounters() Returns live simulation counters: body, shape, contact, joint, and island counts. Useful for debug overlays.
GetJoints(PhysicsBodyComponent, Span<JointComponent>) Returns all joints that body participates in (as either body A or body B), written into results. Returns 0 if the body has no live joints or has not yet been created.
GetJointsAll(PhysicsBodyComponent, List<JointComponent>) Returns all joints that body participates in (as either body A or body B), adding them to results. Clears results before writing. Returns immediately if the body has no live joints or has not yet been created.
GetProfile() Returns a timing breakdown (in milliseconds) for the last Box2D world step. All values are zero before the first call to Brine2D.Physics.PhysicsWorld.Step(System.Single).
GetShapeDistance(PhysicsBodyComponent, PhysicsBodyComponent) Computes the minimum separation distance (or penetration depth) between two live bodies. Iterates over every shape pair across the two bodies and returns the result for the closest (or most-overlapping) pair.
GetShapeDistance(PhysicsBodyComponent, PhysicsBodyComponent, Vector2, Vector2) Computes the minimum separation distance (or penetration depth) between two live bodies. Iterates over every shape pair across the two bodies and returns the result for the closest (or most-overlapping) pair.
GetShapeDistance(PhysicsBodyComponent, PhysicsBodyComponent, Vector2, Vector2, Vector2) Computes the minimum separation distance between two live bodies and returns a separation normal pointing from b toward a — i.e. the direction to push a to resolve the overlap (MTV direction).
GetSleepingBodies() Returns all currently sleeping PhysicsBodyComponent instances (dynamic or kinematic bodies that have come to rest). Returns an empty sequence if no bodies are sleeping or the physics system has not been initialized yet.
IgnoreCollision(PhysicsBodyComponent, PhysicsBodyComponent) Suppresses all collision and contact events between a and b until RestoreCollision(PhysicsBodyComponent, PhysicsBodyComponent) is called. If either body is not yet live, the suppression is deferred and applied automatically the next time both bodies are created. Safe to call multiple times for the same pair.
OverlapAABB(Vector2, Vector2, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) whose AABB intersects the given axis-aligned bounding box, written into results. Use OverlapAABBShapes(Vector2, Vector2, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapAABB(Vector2, Vector2, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) whose AABB intersects the given axis-aligned bounding box, written into results. Use OverlapAABBShapes(Vector2, Vector2, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapAABBAll(Vector2, Vector2, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) whose AABB intersects the given axis-aligned bounding box, adding them to results. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every hit. Use OverlapAABBAllShapes(Vector2, Vector2, List<OverlapHit>, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapAABBAllShapes(Vector2, Vector2, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) within the given axis-aligned bounding box, adding them to results. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every hit.
OverlapAABBFirst(Vector2, Vector2, Nullable<PhysicsQueryFilter>) Returns the first overlapping hit whose AABB intersects the given axis-aligned bounding box, or null if nothing is hit.
OverlapAABBShapes(Vector2, Vector2, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) within the given axis-aligned bounding box, written into results.
OverlapAABBShapes(Vector2, Vector2, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) within the given axis-aligned bounding box, written into results.
OverlapBody(PhysicsBodyComponent, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) whose shapes exactly overlap any shape on body, excluding body itself, written into results. Returns the number of results written. Use OverlapBodyShapes(PhysicsBodyComponent, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapBody(PhysicsBodyComponent, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) whose shapes exactly overlap any shape on body, excluding body itself, written into results. Returns the number of results written. Use OverlapBodyShapes(PhysicsBodyComponent, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapBodyAABB(PhysicsBodyComponent, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) whose AABB overlaps body's AABB, excluding body itself, written into results.
OverlapBodyAABB(PhysicsBodyComponent, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) whose AABB overlaps body's AABB, excluding body itself, written into results.
OverlapBodyAABBAll(PhysicsBodyComponent, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) whose AABB overlaps body's AABB, excluding body itself. Clears results before writing.
OverlapBodyAABBAllShapes(PhysicsBodyComponent, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) whose AABB overlaps body's AABB, excluding shapes belonging to body itself. Clears results before writing.
OverlapBodyAABBFirst(PhysicsBodyComponent, Nullable<PhysicsQueryFilter>) Returns the first overlapping hit whose AABB intersects body's AABB, excluding body itself, or null if none.
OverlapBodyAABBShapes(PhysicsBodyComponent, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) whose AABB intersects body's AABB, excluding body itself, written into results.
OverlapBodyAABBShapes(PhysicsBodyComponent, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) whose AABB intersects body's AABB, excluding body itself, written into results.
OverlapBodyAll(PhysicsBodyComponent, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) whose shapes exactly overlap any shape on body, excluding body itself. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every overlapping body. Use OverlapBodyAllShapes(PhysicsBodyComponent, List<OverlapHit>, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapBodyAllShapes(PhysicsBodyComponent, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits whose shapes exactly overlap any shape on body, excluding shapes belonging to body itself. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every hit.
OverlapBodyFirst(PhysicsBodyComponent, Nullable<PhysicsQueryFilter>) Returns the first overlapping hit whose shapes exactly overlap any shape on body, excluding body itself. Returns null if none or body is not live.
OverlapBodyShapes(PhysicsBodyComponent, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all shape hits whose shapes exactly overlap any shape on body, excluding shapes belonging to body itself, written into results. Returns the number of results written.
OverlapBodyShapes(PhysicsBodyComponent, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits whose shapes exactly overlap any shape on body, excluding shapes belonging to body itself, written into results. Returns the number of results written.
OverlapBox(Vector2, float, float, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given oriented box, written into results. Use OverlapBoxShapes(Vector2, float, float, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapBox(Vector2, float, float, float, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given oriented box, written into results. Use OverlapBoxShapes(Vector2, float, float, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapBoxAll(Vector2, float, float, float, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Tests an oriented box against the world and returns all overlapping bodies (deduplicated by body) into results. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every hit. Use OverlapBoxAllShapes(Vector2, float, float, float, List<OverlapHit>, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapBoxAllShapes(Vector2, float, float, float, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Tests an oriented box against the world and returns all overlapping shape hits (one per shape) into results. Clears results before writing.
OverlapBoxFirst(Vector2, float, float, float, Nullable<PhysicsQueryFilter>) Tests an oriented box against the world and returns the first overlapping hit, or null.
OverlapBoxShapes(Vector2, float, float, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) overlapping the given oriented box, written into results.
OverlapBoxShapes(Vector2, float, float, float, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) overlapping the given oriented box, written into results.
OverlapCapsule(Vector2, Vector2, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given capsule, written into results. Use OverlapCapsuleShapes(Vector2, Vector2, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapCapsule(Vector2, Vector2, float, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given capsule, written into results. Use OverlapCapsuleShapes(Vector2, Vector2, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapCapsuleAll(Vector2, Vector2, float, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given capsule, adding them to results. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every hit. Use OverlapCapsuleAllShapes(Vector2, Vector2, float, List<OverlapHit>, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapCapsuleAllShapes(Vector2, Vector2, float, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Tests a capsule against the world and returns all overlapping shape hits (one per shape) into results. Clears results before writing.
OverlapCapsuleFirst(Vector2, Vector2, float, Nullable<PhysicsQueryFilter>) Tests a capsule against the world and returns the first overlapping hit, or null.
OverlapCapsuleShapes(Vector2, Vector2, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) overlapping the given capsule, written into results.
OverlapCapsuleShapes(Vector2, Vector2, float, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) overlapping the given capsule, written into results.
OverlapCircle(Vector2, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given circle, written into results. Use OverlapCircleShapes(Vector2, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapCircle(Vector2, float, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given circle, written into results. Use OverlapCircleShapes(Vector2, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapCircleAll(Vector2, float, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Tests a circle against the world and returns all overlapping bodies (deduplicated by body) into results. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every hit. Use OverlapCircleAllShapes(Vector2, float, List<OverlapHit>, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapCircleAllShapes(Vector2, float, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Tests a circle against the world and returns all overlapping shape hits (one per shape) into results. Clears results before writing.
OverlapCircleFirst(Vector2, float, Nullable<PhysicsQueryFilter>) Tests a circle against the world and returns the first overlapping hit, or null.
OverlapCircleShapes(Vector2, float, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) overlapping the given circle, written into results.
OverlapCircleShapes(Vector2, float, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) overlapping the given circle, written into results.
OverlapPoint(Vector2, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given point, written into results. Use OverlapPointShapes(Vector2, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapPoint(Vector2, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given point, written into results. Use OverlapPointShapes(Vector2, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapPointAll(Vector2, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given point, adding them to results. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every hit. Use OverlapPointAllShapes(Vector2, List<OverlapHit>, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapPointAllShapes(Vector2, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) at the given point, adding them to results. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every hit.
OverlapPointFirst(Vector2, Nullable<PhysicsQueryFilter>) Returns the first overlapping hit at the given point, or null if nothing is hit.
OverlapPointShapes(Vector2, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) at the given point, written into results.
OverlapPointShapes(Vector2, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) at the given point, written into results.
OverlapPolygon(ReadOnlySpan<Vector2>, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given convex polygon, written into results. Vertices are in world space (3–8 vertices). Use OverlapPolygonShapes(ReadOnlySpan<Vector2>, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapPolygon(ReadOnlySpan<Vector2>, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given convex polygon, written into results. Vertices are in world space (3–8 vertices). Use OverlapPolygonShapes(ReadOnlySpan<Vector2>, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapPolygonAll(ReadOnlySpan<Vector2>, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all bodies (deduplicated by body) overlapping the given convex polygon into results. Clears results before writing. Retries with a larger internal buffer if needed — guaranteed to return every hit. Vertices are in world space (3–8 vertices). Use OverlapPolygonAllShapes(ReadOnlySpan<Vector2>, List<OverlapHit>, Nullable<PhysicsQueryFilter>) for per-shape granularity.
OverlapPolygonAllShapes(ReadOnlySpan<Vector2>, List<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) overlapping the given convex polygon into results. Clears results before writing. Vertices are in world space (3–8 vertices).
OverlapPolygonFirst(ReadOnlySpan<Vector2>, Nullable<PhysicsQueryFilter>) Returns the first overlapping hit within the given convex polygon, or null if none. Vertices are in world space (3–8 vertices).
OverlapPolygonShapes(ReadOnlySpan<Vector2>, Span<OverlapHit>, bool, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) overlapping the given convex polygon, written into results. Vertices are in world space (3–8 vertices).
OverlapPolygonShapes(ReadOnlySpan<Vector2>, Span<OverlapHit>, Nullable<PhysicsQueryFilter>) Returns all shape hits (one per shape) overlapping the given convex polygon, written into results. Vertices are in world space (3–8 vertices).
Pause() Pauses the world. Brine2D.Physics.PhysicsWorld.Step(System.Single) becomes a no-op until Resume() is called. In-flight contacts and sensor pairs are preserved; no exit events are fired on pause.
PurgePendingIgnoredPairsForComponent(PhysicsBodyComponent) Removes all pending deferred IgnoreCollision(PhysicsBodyComponent, PhysicsBodyComponent) entries that reference body. Called when a body component is destroyed so stale pending entries do not accumulate.
RaycastAll(Vector2, Vector2, float, List<RaycastHit>, Nullable<PhysicsQueryFilter>) Casts a ray and returns all hits (deduplicated by body, sorted nearest-first) into results. Unlike the System.Span<> overloads, this variant retries with a larger internal buffer if needed and is guaranteed to return every hit. Clears results before writing.
RaycastAll(Vector2, Vector2, float, Span<RaycastHit>, bool, Nullable<PhysicsQueryFilter>) Casts a ray and returns all hits sorted by distance, deduplicated by body (one entry per body), written into the caller-provided buffer. Use RaycastAllShapes(Vector2, Vector2, float, Span<RaycastHit>, bool, Nullable<PhysicsQueryFilter>) when you need per-shape granularity on compound bodies.
RaycastAll(Vector2, Vector2, float, Span<RaycastHit>, Nullable<PhysicsQueryFilter>) Casts a ray and returns all hits sorted by distance, deduplicated by body (one entry per body), written into the caller-provided buffer. Use RaycastAllShapes(Vector2, Vector2, float, Span<RaycastHit>, bool, Nullable<PhysicsQueryFilter>) when you need per-shape granularity on compound bodies.
RaycastAllShapes(Vector2, Vector2, float, List<RaycastHit>, Nullable<PhysicsQueryFilter>) Casts a ray and returns all shape hits (not deduplicated, sorted nearest-first) into results. Unlike the System.Span<> overloads, this variant retries with a larger internal buffer if needed and is guaranteed to return every hit. Clears results before writing.
RaycastAllShapes(Vector2, Vector2, float, Span<RaycastHit>, bool, Nullable<PhysicsQueryFilter>) Casts a ray and returns all shape hits sorted by distance, without deduplicating by body. Compound bodies with multiple shapes can appear more than once in the results. Use this when you need to know exactly which shape on a body was hit.
RaycastAllShapes(Vector2, Vector2, float, Span<RaycastHit>, Nullable<PhysicsQueryFilter>) Casts a ray and returns all shape hits sorted by distance, without deduplicating by body. Compound bodies with multiple shapes can appear more than once in the results. Use this when you need to know exactly which shape on a body was hit.
RaycastClosest(Vector2, Vector2, float, Nullable<PhysicsQueryFilter>) Casts a ray through the world and returns the closest hit. Returns null if nothing was hit.
ResetForTesting() Resets the process-wide Box2D.NET.Bindings.B2.SetLengthUnitsPerMeter(System.Single) lock. Intended for use in unit tests only — do not call in production code.
RestoreCollision(PhysicsBodyComponent, PhysicsBodyComponent) Restores normal collision between a and b after a previous IgnoreCollision(PhysicsBodyComponent, PhysicsBodyComponent) call. Also cancels any pending deferred ignore for this pair. Safe to call when the pair was not ignored.
Resume() Resumes a paused world.
SetContactHitEventThreshold(float) Sets the minimum closing speed (pixels/s) at which a contact fires OnCollisionHit. Lower values make hit events more sensitive; set to 0 to fire on every contact.
SetContinuousEnabled(bool) Enables or disables continuous collision detection (CCD) for the world. When disabled, fast-moving bodies may tunnel through thin shapes. Default is enabled. Per-body bullet mode (IsBullet) is unaffected by this setting and will still use sub-step CCD.
SetCustomCollisionFilter(Func<PhysicsBodyComponent,PhysicsBodyComponent,bool>) Registers a user-level collision filter invoked for every potential contact pair. Return false to prevent the pair from colliding. Pass null to remove it. This filter is evaluated after per-body ShouldCollide and per-sub-shape ShouldCollide checks — all must pass for a contact to proceed. The callback is invoked from the Box2D broad-phase during fixed-update — keep it allocation-free.
SetGravity(Vector2) Sets world gravity at runtime in pixels per second squared. All awake dynamic bodies are affected immediately.
SetMaxLinearSpeed(float) Sets the maximum linear speed (pixels/s) a body can reach. Box2D clamps body velocity to this value each step. Useful as a safety cap in particle-heavy or high-impulse scenes. Must be greater than zero.
SetPreSolveFilter(Func<PreSolveContact,bool>) Registers a pre-solve filter invoked by the Box2D solver for every active contact pair each step, before collision impulses are applied. Return false to cancel the contact for that step — no forces are applied and no collision events fire for the pair that step, but the pair remains active and is re-evaluated next step. Pass null to remove the filter.
SetRestitutionThreshold(float) Sets the minimum impact speed (pixels/s) required for restitution (bounciness) to be applied. Below this threshold contacts are treated as inelastic. Set to 0 to always apply restitution. Leave unset to use the Box2D default.
SetSleepingEnabled(bool) Enables or disables body sleeping. When disabled, all bodies stay awake permanently.
ShapeCastAll(Vector2, float, float, float, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAll(Vector2, float, float, float, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, float, float, float, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, float, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAll(Vector2, float, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, float, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, Vector2, float, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAll(Vector2, Vector2, float, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(Vector2, Vector2, float, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins).
ShapeCastAll(ReadOnlySpan<Vector2>, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns all hits (deduplicated by body, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAll(ReadOnlySpan<Vector2>, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins). Vertices are in world space at the start of the sweep.
ShapeCastAll(ReadOnlySpan<Vector2>, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns all hits sorted by distance, deduplicated by body (one hit per body, nearest shape wins). Vertices are in world space at the start of the sweep.
ShapeCastAllShapes(Vector2, float, float, float, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAllShapes(Vector2, float, float, float, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Compound bodies may appear more than once.
ShapeCastAllShapes(Vector2, float, float, float, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Compound bodies may appear more than once.
ShapeCastAllShapes(Vector2, float, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAllShapes(Vector2, float, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Compound bodies may appear more than once.
ShapeCastAllShapes(Vector2, float, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Compound bodies may appear more than once.
ShapeCastAllShapes(Vector2, Vector2, float, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAllShapes(Vector2, Vector2, float, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Compound bodies may appear more than once.
ShapeCastAllShapes(Vector2, Vector2, float, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Compound bodies may appear more than once.
ShapeCastAllShapes(ReadOnlySpan<Vector2>, Vector2, float, List<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Retries with a larger internal buffer if needed — guaranteed to return every hit. Clears results before writing.
ShapeCastAllShapes(ReadOnlySpan<Vector2>, Vector2, float, Span<ShapeCastHit>, bool, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Compound bodies may appear more than once. Vertices are in world space at the start of the sweep (3–8 vertices).
ShapeCastAllShapes(ReadOnlySpan<Vector2>, Vector2, float, Span<ShapeCastHit>, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns all shape hits (not deduplicated, sorted nearest-first) into results. Compound bodies may appear more than once. Vertices are in world space at the start of the sweep (3–8 vertices).
ShapeCastClosest(Vector2, float, float, float, Vector2, float, Nullable<PhysicsQueryFilter>) Sweeps an oriented box along a direction and returns the closest hit.
ShapeCastClosest(Vector2, float, Vector2, float, Nullable<PhysicsQueryFilter>) Sweeps a circle along a direction and returns the closest hit.
ShapeCastClosest(Vector2, Vector2, float, Vector2, float, Nullable<PhysicsQueryFilter>) Sweeps a capsule along a direction and returns the closest hit.
ShapeCastClosest(ReadOnlySpan<Vector2>, Vector2, float, Nullable<PhysicsQueryFilter>) Sweeps a convex polygon along a direction and returns the closest hit. Vertices are in world space at the start of the sweep.