Skip to content

Debug Draw

The physics debug draw overlay renders wireframe outlines for all colliders, velocity arrows, and contact points. It uses the engine’s Draw API and works in both the editor and at runtime.

Enabling Debug Draw

import { Physics } from 'esengine/physics';
// Toggle debug draw on/off
Physics.setDebugDraw(app, true);

Configuration

Control which elements are visualized:

import { Physics } from 'esengine/physics';
Physics.setDebugDrawConfig(app, {
enabled: true,
showColliders: true, // wireframe collider outlines
showVelocity: true, // velocity arrows on dynamic bodies
showContacts: false, // contact point markers
});
PropertyTypeDefaultDescription
enabledbooleanfalseMaster toggle for debug drawing
showCollidersbooleantrueDraw collider wireframes
showVelocitybooleanfalseDraw velocity arrows on dynamic bodies
showContactsbooleanfalseDraw contact points on collision enter

Color Coding

Collider outlines are color-coded by body type:

Body TypeColor
StaticBlue
DynamicGreen
KinematicCyan
SensorYellow (semi-transparent)

Velocity arrows are drawn in red. Contact points are shown as red dots.

PhysicsDebugDraw Resource

For advanced control, access the PhysicsDebugDraw resource directly:

import { PhysicsDebugDraw } from 'esengine/physics';
const config = app.getResource(PhysicsDebugDraw);
config.enabled = true;
config.showVelocity = true;
app.insertResource(PhysicsDebugDraw, config);

See Also