Skip to content

Kinematic platform

Kinematic bodies are moved by you, not by forces — but they still push dynamic bodies correctly. The trick is moveKinematic, which sets a velocity so the body arrives at the target next step, rather than teleporting. That carried velocity is what lets a platform ferry its cargo and bulldoze loose boxes.

Drag to orbit

Loading physics…
const platform = world.createBody({
type: "kinematic",
shape: Shape.box({ halfExtents: [1.4, 0.15, 1.4] }),
position: [-3, 0.5, 0],
layer: "moving",
});
let time = 0;
function tick(dt) {
time += dt;
const x = Math.sin(time * 0.7) * 3; // where the platform should be next
platform.moveKinematic([x, 0.5, 0], [0, 0, 0, 1], dt);
world.step(dt);
}