Skip to main content

Physics

Physics makes objects fall, collide and bounce. Here is what is solid, where collision shapes come from, and how to move a physics object.

Most of it works on its own. The floor is solid without any setup, and objects you make dynamic fall.

What counts as solid​

An object is solid if you gave it a rigid body. It is also solid if it has a shape and is not already part of a body higher up in the tree. So the floor stops you because it is a floor. You do not have to mark it.

Check an object like this:

The object has…Result
a rigid bodyit is its own body
a rigid body set to Nonenothing here is solid, including its children
a collider, even an invisible onesolid
geometry, and it is visiblesolid
geometry, but it is hiddennot solid
none of the above (a group, a light)not solid

Two useful rules follow from this:

  • A collider stays solid when it is invisible. That is how you build an invisible wall: add a collider and no geometry. Visitors bump into it but see nothing.
  • Geometry is solid only while it is visible. Hide a decorative shape, and it stops blocking things too.
Hiding part of a body does not remove it

Once a shape has joined a larger body, it stays in it even when hidden. To take it out, remove the object or set its rigid body to None.

Collision shapes​

If an object has a collider, physics uses it. If not, the engine makes a shape from the geometry:

GeometryCollision shape
box, sphere, cylinder, capsule, conethe matching shape
the three polyhedraan exact outer shape
plane, circle, ring, trianglea thin slab, solid from both sides
torusan approximate ring
extrude, lathea shape that follows the mesh exactly
an imported 3D modelnone — see below
Imported models are not solid without a collider

This is the most common physics surprise. Drop a GLB model into a scene, make it dynamic, and it falls through the world. Add a collider and it behaves. A box or a capsule is almost always the right choice.

Use exact mesh shapes only for things that never move

A mesh shape (from extrude, lathe or imported geometry) is fine for a static floor or wall. On a moving object it passes through things and jitters. Use a box, sphere, capsule or cylinder instead. Simple shapes are also much faster.

Scaling an object also scales its collision shape.

Move a physics object​

Setting a dynamic body's position does nothing

Physics controls where a dynamic body is. It overwrites your change on the next step, so it looks as if your change was ignored.

  • To push the body, use an impulse or a force.
  • To put it somewhere, use a teleport: for respawns, checkpoints or going back to the start.

In a script, use ctx.physics.teleport(...) and ctx.physics.applyImpulse(...). See the ctx reference. For a walking character, use game controls. They handle all of this for you.

Reading how fast an object is moving is cheap, but the value is about one frame behind. It is good for checking "is it moving?", but not for exact maths.

World settings​

Gravity, default friction, bounciness and solver quality are set for the project. You can override them for each space. Changes apply right away, with no restart.

Each body can override friction and bounciness. If you leave them alone, the body uses the world settings.

Collisions​

When two objects touch, both get an on-collide event, and each learns what it hit. In the event, you can limit it to specific objects or leave it open to any object.

Collisions do not pass up to parents

A tap passes up to parent objects, but a collision does not. It fires only on the objects that actually touched. Put the event on the object that does the colliding.

Where physics runs​

  • In the browser: yes.
  • In the AR Clip app (mobile): yes.
  • In the editor: no. Nothing falls while you work.

When your project runs, physics starts only if a scene needs it. A scene needs it when it has something dynamic or kinematic, game controls, or a body plus a script. A scene with only static objects does not need physics, so it opens faster.

If a script creates a ball in the middle of a session, physics starts then.


Next: Lights — light types and what changes smoothly in transitions.