Skip to content

PhysicsAPI reference

Namespace MicroEngine.Physics

The 2D physics contract: worlds of bodies owned by entities, box shapes with collision layers, collide-and-slide moves with their contacts, ray and overlap queries, sensors with buffered events, declared capabilities and the typed capability error, and the module that steps worlds and writes body poses to transforms.

Guide: Physics worlds

Namespaces

MicroEngine.Physics.Tiles

Classes

CollisionLayers

The collision layers of the contract: 64 bits, any meaning the game gives them. A shape is in the layers of its Category and collides with the layers of its Mask; two shapes collide only when each one’s mask holds the other’s category.

PhysicsCapabilityException

A request needed a physics capability the backend does not declare (Capabilities). It is thrown before anything changes: the world is as it was.

PhysicsContract

The version of the 2D physics contract (IPhysicsWorld2D); a change to its rules raises it.

PhysicsModule

The physics module: registers a PhysicsSystem service and steps it in Physics (system SystemName), once per fixed step, after the simulation’s FixedUpdate.

PhysicsSync

Copies body poses to the transforms of the entities that own them.

PhysicsSystem

Steps physics worlds, each optionally bound to the scene world whose entities own its bodies. A bound physics world steps only in the engine steps its scene world stepped in, by that world’s scaled step (Delta), so a paused, frozen or covered scene’s physics stands still too; after the step, the pose of every kinematic and dynamic body is written to its owner’s transform (WriteTransforms), which the scene world interpolates for drawing. An unbound world steps by the engine’s fixed step.

Structs

BodyDescription

What CreateBody creates.

BodyId

A body of an IPhysicsWorld2D: a slot index and the generation of the body that held the slot when the id was made. A destroyed body’s slot is reused with a new generation, so an old id never reaches the new body. default is None (generation 0 is never issued).

ContactEvent

Two shapes began or stopped touching during the latest Step; only pairs with at least one dynamic body report them (a kinematic body’s contacts come from MoveResult).

MoveContactBuffer

The contacts of one MoveResult, stored inline (no allocation).

MoveContact

A surface a moving body touched (Contacts).

MoveResult

What Move did: where the body ended, how far it went, and every surface it was stopped by or touches at the end (within the backend’s Skin), each one with its normal. A kinematic body’s contacts and its ground come from here, never from ContactEvents.

QueryFilter

Which shapes a query (RayCast, Overlap) or a Move considers. A shape matches when its category is in the filter’s Mask and the filter’s Category is in the shape’s mask. default is Default: category Default, every layer, sensors left out.

RayHit

The closest shape a ray hit (RayCast).

SensorEvent

A shape entered or left a sensor during the latest Step. The ids and owners are copied when the event is made, so an exit caused by destroying a shape still names it.

ShapeDescription

What AddShape attaches to a body. Build one with Box (common) or a capability’s factory.

ShapeId

A shape of an IPhysicsWorld2D (a box, a tile grid, or a shape of a declared capability), attached to one body. Generation-checked like BodyId; default is None.

Interfaces

IPhysicsWorld2D

A 2D physics world: bodies owned by entities, shapes with collision layers, kinematic collide-and-slide moves, ray and overlap queries, sensors, and a step. The members below are the common contract every backend passes (one conformance suite); everything else is a declared capability (Capabilities), and a request that needs an undeclared one throws PhysicsCapabilityException without changing the world.

Enums

BodyKind

How a body moves.

ContactEventKind

Whether a contact event is a begin or an end.

PhysicsCapabilities

What a physics backend offers beyond the common contract of IPhysicsWorld2D. Every backend passes the common conformance suite; each flag it declares has a suite of its own that runs only on backends declaring it. A request that needs an undeclared flag fails with PhysicsCapabilityException: a backend never emulates a capability silently.

SensorEventKind

Whether a sensor event is an entry or an exit.

ShapeKind

The geometry of a shape.