Rigidbody2D
Optional feature
Rigidbody2D is part of 2D Physics. A build includes it only when a scene, prefab or script uses it — see Feature cropping.
From a script
ts
import { Rigidbody2DComponent } from "mmpx";
const rigidbody2D = this.entity.TryGetComponent(Rigidbody2DComponent);Full API: Rigidbody2DComponent.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
Body TypebodyType | "dynamic" | "kinematic" | "static" | "dynamic" | Dynamic: moved by forces and collisions. Kinematic: moved only by velocity / MovePosition, pushes dynamic bodies, unaffected by them. Static: never moves (but follows its Transform) |
Use Auto MassuseAutoMass | boolean | false | Mass from the colliders' density × area (kg per square metre) |
Massmass | number (0.0001 … ∞) (kg) | 1 | |
Linear DampinglinearDamping | number (0 … ∞) | 0 | Slows the movement down over time (air drag) |
Angular DampingangularDamping | number (0 … ∞) | 0.05 | Slows the spin down over time |
Gravity ScalegravityScale | number | 1 | Multiplies the world gravity for this body (0 = floats) |
Freeze RotationfixedRotation | boolean | false | Never rotates (characters) |
Collision DetectioncollisionDetection | "discrete" | "continuous" | "discrete" | Continuous keeps fast bodies (bullets) from tunnelling through other moving bodies — costs more |
Sleeping ModesleepMode | "startAwake" | "startAsleep" | "neverSleep" | "startAwake" | A resting body sleeps (costs nothing) until something touches it |
Interpolationinterpolation | "none" | "interpolate" | "interpolate" | Smooths the drawn movement between physics steps (when frames outnumber ticks) |