Phaser AE

3D tag collision rules

Free packv3.0.0-23DPhysics

Overlap rules by tag in a 3D world, with no dynamics. Pickups, bullets, triggers and a player who walks on floors and stops at walls all work by naming two tags and saying what happens when they meet, with the same calls as the 2D `collision` pack.

This is a Free pack. Every phaser.io account can use it in their games.

Released October 14, 2026 · updated October 19, 2026

3D tag collision rules: a screenshot of its demo
A note about these graphics

Expansion packs don't come with graphics. This screenshot is one way of drawing what the pack does, made for its demo: none of the sprites, tiles or backgrounds in it are in the pack.

That's by design. A pack is a game's logic, mechanics and effects, and it works with whatever art you give it. Some packs draw effects, backdrops or 3D scenes of their own, but none carries a game's sprites.

So the look is yours. Make the art on phaser.io, bring your own, or let your agent draw it in code: the same pack can look like anything.

What it does

Every object in the 3D world has a collision shape. By default it is a box the size of its mesh: the engine's meshes are unit-sized and scaled, so the box is simply the object's scale on each axis. Where that is wrong, you give the object a shape as spawn data, or later with shape(h, …): a sphere, a box of another size, or one moved off the origin, such as a character model's box that sits on its feet rather than round its middle. With model-3d composed, a loaded model offers a box built from its own parts, and a shape the game gives still wins.

Rules name two tags. on calls back for every overlapping pair each fixed step, after the game's own steps and after physics-3d, and solid keeps one kind of thing out of another by moving it along the axis where they overlap least. The callback receives a contact: the side of the first object the second is against (left, right, bottom, top, back or front, with y up) and how deep. A player whose contact with the floor is 'bottom' is standing on it, which is all a simple 3D platformer needs to know.

Because the calls match the 2D pack's (on, solid, overlaps, test, contact, raycast), rules written for a 2D game read the same in 3D, with a z added. Rules belong to the scene that made them and leave with it, and destroying either object inside a callback is safe: the pair is not separated, and the object meets nothing else that step.

Features

  • The same calls as 2D — on, solid, overlaps, test, contact and raycast, on game.collide.
  • Boxes and spheres — a box from the mesh's scale by default, or shape, size, radius and offset as spawn data, in the object's own units so its scale multiplies them.
  • Six-sided contacts — which face of the first object the second touches, and how deep, read before separation.
  • Solid separation — push the first object, the second or both, along the shallowest axis.
  • Raycasts — the nearest object along a ray within a distance, optionally of one tag, with the hit point and the distance.
  • Model boxes — with model-3d, a loaded model's box comes from its parts with no spawn data at all.
  • Scene-scoped rules — rules leave with the scene that made them.

Good for

  • 3D collectathons and platformers — coins and gems to pick up, floors to stand on and walls to stop at, without a physics engine.
  • 3D shooters — shots against enemies, and a raycast for hitscan weapons and lines of fire.
  • Triggers and zones — doors, checkpoints and level exits in any 3D game.
  • 3D runners and lane games — obstacles and pickups along the track, tested by tag.
  • A 2D game moving to 3D — its collision rules carry across under the same names.

Make it yours

There are no pack options: the shapes and the rules are the configuration. Give each kind of object the shape that matches what the player sees, set an offset for models whose origin is at their feet, and choose for each solid rule which side moves.

Two different uses: a coin-collecting platformer where the hero has a size: [0.6, 1.8, 0.4] box lifted by offset: [0, 0.9, 0], walls are solid, and a 'bottom' contact with a platform marks the hero as grounded; and a 3D arena shooter where enemies are spheres, shots use on rules, and a raycast from the player picks the first enemy in the line of fire.

A quick look

Pickups, walls, crates that push each other, a sphere and a hero whose box sits on its feet:

game.collide.on('player', 'coin', (p, coin) => { coin.destroy(); score += 1; });
game.collide.solid('player', 'wall');                       // keep the player out of walls
game.collide.solid('crate', 'crate', { push: 'both' });
game.spawn({ id: 'ball', mesh: 'sphere', x, y, z, tags: ['ball'], collide: { shape: 'sphere' } });
game.spawn({ id: 'hero', model: 'hero', x, y: 0, z, tags: ['hero'], collide: { size: [0.6, 1.8, 0.4], offset: [0, 0.9, 0] } });
const hit = game.collide.raycast(x, y, z, dx, dy, dz, 50, 'enemy');   // nearest along the ray, or null

Works with

  • core-3d — includes this pack, so most 3D games have it already.
  • physics-3d — for things that need mass, gravity and spin; these rules run after it.
  • model-3d — gives loaded models a box built from their parts.
  • collision — the 2D version; a game composes one or the other, since both are game.collide.

Good to know

  • Boxes stay upright: a turned box is tested as if it were not turned. For turned boxes that rest on each other, use physics-3d.
  • solid separates a sphere as its bounding box, and raycast tests a sphere as its box.
  • Every pair of a rule's two tags is tested each step, so rules suit tens to hundreds of objects, not thousands.
  • It is positional only: solid moves things apart and never changes a velocity your game keeps.

More Physics packs

Show all →