Engine.js includes a built-in physics layer that can apply gravity to any figure and resolve collisions between objects. Physics is opt-in: by default a figure is static and stays exactly where you place it. To make a figure fall, bounce, or react to other bodies, attach a Rigido (rigid body) to it.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/OmarMtya/engine.js/llms.txt
Use this file to discover all available pages before exploring further.
What Rigido does
A Rigido component enables two behaviours for the figure it is attached to:
- Gravity simulation — the figure accelerates downward each frame, scaled by the
valorproperty. - Collision detection — the engine checks for overlaps with other rigid bodies and resolves them automatically.
Rigido is attached. You can suppress collision detection individually per object using the sinColision flag.
Adding a rigid body
Assign a new$g.Rigido instance to figura.rigido, then set properties directly on the instance:
Properties
Gravity strength applied to the figure each frame. Higher values cause the figure to fall faster. A value of
0.5 is a gentle pull; 2.0 or more is a strong pull.When
true, collision detection is disabled for this figure — it falls through other objects. When false, the engine resolves overlaps with other rigid bodies.Removing physics
Setfigura.rigido to null to detach physics entirely. The figure immediately becomes static:
Full example
Collision detection
When two figures both have aRigido attached and neither has sinColision: true, the engine detects overlapping bounds and prevents them from passing through each other. No additional configuration is needed — attaching a Rigido to both objects is sufficient.
Sound on collision
Sounds can be wired to physics events. Attach a$g.Sonido to figura.transform.sonido with the appropriate activacion value:
'colision'— plays when this figure begins overlapping another rigid body.'colisionInversa'— plays when this figure stops overlapping another rigid body.
Sonido reference.
Physics property reference
| Property | Type | Description |
|---|---|---|
figura.rigido | Rigido | null | The rigid body component. null means no physics. |
figura.rigido.valor | number | Gravity strength per frame. |
figura.rigido.sinColision | boolean | true disables collision response for this figure. |