Mgameplay

deki-physics-2d

2D physics: rigid bodies, box, circle, capsule and polygon colliders, triggers, raycasts, hinges and ropes, on a fixed step so a game plays the same at any frame rate.

Rigid bodies that move and turn, with box, circle, capsule and convex polygon colliders of up to 8 corners. A body falls, balances and spins about the centre of its colliders, and bodies at rest go to sleep, with everything touching them, until something wakes them.

PartWhat it does
Rigidbody2DDynamic (moved by physics), kinematic (moved by code, pushes others) or static
CollidersBox, circle, capsule and polygon, with friction and bounciness; triggers report without colliding
JointsHinges with limits and a motor, distance joints and ropes
QueriesRaycasts, layers, and callbacks when two things touch

Physics runs on a fixed step, so a game plays the same at any frame rate. Each step is solved in sub-steps, which lets the weight of a stack reach the ground: ten boxes stand however they are set down, twenty with six sub-steps, the same on a desktop and on a board. Fast bodies stop at what they would otherwise jump over in one step.

Colliders and joints are drawn in the Scene View, with handles to drag a selected collider’s size and corners. Details are in the README.

Questions

Does Deki have physics?

Yes, 2D physics, from Deki 0.40: add a Rigidbody 2D and a collider to an object and it falls, stacks, bounces and slides. Hinges, distance joints and ropes join bodies together.

Does it run on a microcontroller?

Yes. On a LilyGO T-Deck, 30 boxes moving cost 1.6 ms a step, and a pile that has come to rest costs almost nothing. Nothing is allocated while a scene runs.

Will a stack that stands on my computer stand on the device?

Yes. The step is fixed and solved in sub-steps, so a stack of ten boxes stands however it is set down, on a desktop and on an ESP32-S3 alike.

Sponsors

all thanks →

Companies that provide hardware so Deki can run on it. Each board gets an official Deki package, kept maintained, with examples ready to run.

Friends

Projects whose work Deki uses or runs on.