Collisions & Platformer Physics
Collision detection tells you when two hitboxes touch (like picking up a coin or firing a laser). Physics resolution (KinematicBody) stops your hero at solid walls, glides up slopes, and lands on one-way ledges.
1. Hitboxes, Layers & Raycasts (CollisionSystem)
Layers & masks act like team jerseys—friendly items don't block you, while enemies trigger onCollisionEnter. A raycast() shoots an invisible laser line to find the closest target.
const hit = collisions.raycast(this.Elements.All, ox, oy, 1, 0, 400, LAYER_ENEMY);
PoC 1 — Hitboxes,
queryRect() Radar & raycast() LaserDrag or move HERO (WASD/Arrows when focused) into ORC boxes to trigger Enter/Exit, or click "Fire Raycast".
2. Platformer Physics: Slopes & One-Way Ledges (KinematicBody)
Use KinematicBody with slope: 'right' ramps and oneWay: true jump-through ledges for smooth platforming.
const body = new KinematicBody({ gravityY: 760, frictionX: 900 });
const move = body.step(hero, solidWalls, dt, collisions);
PoC 2 — Platformer with Slopes & One-Way Ledges
Click canvas & use A/D or Arrow Keys to walk up the orange ramp and Space to jump onto the cyan one-way ledge!