FERRETGame engine over Babylon.js
Ferret

Interaction and zones

Skill ferret-interaction-zones · download all skills · SKILL.md

When to use#

Doors, levers, pickups, inventories, "enter this area" triggers.

The model#

Interactor on the player picks the usable thing in front of it each step and shows its prompt; Interactable is the base. On top: Door, LevelDoor (using it calls travel), Lever (flips and toggles the doors it points at), Pickup, Inventory. installInteraction(world) registers them so manifests can name them. ZoneService keeps named zones on a grid; a member is in exactly one zone at a time; events on enter and exit. zoneHash gives the name a backend sees.

Steps#

  1. installInteraction(world); add Interactor to the player.
  2. In the manifest: entity { node, behaviour: "Door", params: { slide: [0, 2.4, 0] } }, pickups with item.
  3. Zones: manifest zones (names, shapes) or the editor commands edit.zone.*.
  4. Listen to the zone events for ambient sound, voice rooms, transformations.

Check afterwards#

Walk up to each usable: prompt appears (UI setPrompt), use works with action A/Enter; a zone fires once on enter and once on exit.

What usually goes wrong#

  • No ZoneService added to the world: zones silently do nothing.
  • Overlapping zones: a member belongs to one; use priority.
  • The player lacks Interactor, or the usable is out of range or not in front.

Files#