Simulation

Built-In Physics

Real simulation. Zero setup. Box2D at the core.

Formo ships a full rigid-body physics engine powered by planck.js — a ~40KB Box2D port. No approximations, no tweening hacks. Real forces, real collisions, real contact response.


One-Click Setup

Add the physics module to any node. Pick a body type. Press play. Gravity pulls at 9.8 m/s² and collisions just work.

3 Body Types

TypeBehavior
DynamicAffected by forces, gravity, and collisions. The default for game objects.
StaticImmovable. Walls, floors, platforms. Zero mass, infinite inertia.
KinematicMoved by code only. Elevators, moving platforms, scripted obstacles.

Switch between them with the TripleToggle control — one click, no dropdowns.

Falling shapes

Dynamic shapes collide with a static platform — restitution controls bounce


Automatic Colliders

The engine reads your shape type and generates the right collider — no manual setup.

ShapeColliderNotes
RectangleBoxAxis-aligned, matches width and height
EllipseCircleUses the larger radius
PolygonConvex polygonUp to 8 vertices, auto-decomposed

Coordinate conversion uses PIXELS_PER_METER = 50. A 100px square becomes a 2m box in the physics world.

Multi-Collider Bodies

One node can hold multiple named colliders with independent type, scale, and offset. Build an L-shaped wall from two box colliders. Give a character a wide foot sensor and a narrow body hitbox. Add and remove colliders in the ColliderGroup panel.


Material Properties

Every collider exposes 7 tunable properties. Drag the SliderInput controls — pointer-lock gives you infinite drag range.

PropertyRangeDefaultEffect
density0 – 1001.0Mass per unit area
friction0 – 10.3Surface grip between bodies
restitution0 – 10.0Bounciness on impact
gravityScale-10 – 101.0Per-body gravity multiplier
fixedRotationboolfalsePrevents angular velocity
fixXboolfalseLocks horizontal movement
fixYboolfalseLocks vertical movement

FixToggle buttons lock axes instantly. Position is captured when toggled — no drift.


Collision Events

The collide event fires on contact with full context.

// event properties
event.target         // the other node
event.normal         // contact normal vector
event.point          // world-space contact point
event.collider       // this node's collider name
event.targetCollider // other node's collider name

Write game logic directly in the handler:

if (event.target.is("brick")) {
  event.target.destroy()
  Score.text = Tag.brick.length
}

Sensor Colliders

Set this.sensor = true on any collider. It detects overlaps but generates no physical response — perfect for triggers, pickups, and damage zones.

Collision Bypass

Call this.disableCollisions(otherNode) to let two specific bodies pass through each other. Re-enable with this.enableCollisions(otherNode).


Formula Integration

Physics properties are first-class formula targets. Read velocity, apply forces, control movement — all from expressions.

this.velocityX            // read horizontal velocity
this.velocityY            // read vertical velocity
this.applyForce(x, y)    // continuous force (newtons)
this.applyImpulse(x, y)  // instant momentum change

The VelocityWidget shows a direction dial and magnitude — drag to set initial velocity visually before play.

Force-driven platformer

Arrow keys apply forces to a dynamic body on a static floor


Nested Physics

Physics works inside transformed containers. The engine resolves parent rotation, scale, and translation before syncing positions — bodies inside a rotated group collide correctly.


Stable Simulation

The engine uses a fixed-timestep accumulator. Physics steps at a constant rate regardless of frame rate — 60fps or 144fps, the simulation produces identical results. No frame-dependent jitter, no tunneling at low FPS.


Non-Destructive Play

Press play — the engine snapshots every node’s position, rotation, and velocity. Physics runs. Shapes fly, bounce, collide. Press stop — everything resets to the exact captured state. Iterate without fear.

Breakout prototype

Ball bounces between walls and destroys tagged bricks on collision


Start building

Real physics. Visual controls. Formula-driven logic. Open Formo and drop a ball.

Open Formo →