Log inGet started
← Explore
World media

Watchful Minds: NPC Brains and Perception Kit

Walk into a ring of 15 live areas, one per behaviour and perception style: guards on patrol, a sniper on its perch, a swarm, a turret, a companion, a three-phase boss, a sight-cone sentry, a blind listener and a night watch you can sneak past in the dark. Press V to see what every character sees, hears and remembers, G to throw a bottle and F to fire a shot. Everything here ships as aiKit 1.2.5: put a Brain on a character, pick one of 16 presets and press play. Install aiKit.package from ZeroMind into /source in one step (navKit and SecondWind come along with it); two guides inside teach you to build enemies that patrol, chase and attack the player.

0score
Embed

Embed this world

Paste this code into your own page and the world plays right there.

Updated Nov 1, 2026
ainpcenemybrainbehaviour-treestate-machineperceptionvision-conehearingstealthmultiplayerpresetskit

Watchful Minds: aiKit 1.2.5

Enemy, ally and creature brains for your world, without writing enemy logic. aiKit gives non-player characters senses, memory and decisions. It's made for stealth games, shooters, RPGs, horror games and tower defences.

Put a Brain on a character, pick a preset, press play. Change the preset while the game runs and the character behaves differently at once.

What you get

  • 16 ready presets. Twelve behaviours: guard on patrol, wanderer, melee chaser, ranged attacker that keeps its distance, coward that flees when hurt, ambusher, sniper, healer, swarm member, turret, companion that follows and helps a player, and a boss that changes tactics in three phases. Three perception styles: a sight-cone sentry, a blind listener that hears all round, and a light-sensitive night watch you can sneak past in the dark. Plus a training dummy. Find them by tag: AI.find({ tag = "ranged" }).
  • Pick a perception style by its tags. AI.styles("night-levels"), AI.styles("stay-quiet"): each style is tagged by what it senses with (sight, hearing, light), what it suits (stealth, horror, guard posts, night levels) and how a player beats it (hide behind walls, stay quiet, stay in the dark).
  • Presets are plain data. Make "a guard that hears better but gives up later" by changing two numbers, no code: AI.definePreset("eagleGuard", { base = "guard", senses = { hearing = { sensitivity = 2 } }, search = { time = 25 } }).
  • Honest senses. Sight in a cone that walls block. Hearing of the noises your game makes (footsteps, gunshots, a thrown bottle), fading with distance and muffled by walls. Optional sight that needs light. A memory of where it last saw or heard someone, fading over time. Characters only ever act on where a player was.
  • Two ways to build your own brains. A small state machine and a small behaviour tree, both used by the built-in presets.
  • A debug view in the game view. Press V while playing to see every character's state, vision cone, hearing range, what it heard and the spots it remembers; B switches between full, labels-only and cones-only.
  • Multiplayer. The host runs the brains; every player sees the same characters in the same places doing the same things, and any player can be the one they chase, shoot at or follow.
  • Built on two published kits. navKit moves the characters; SecondWind handles health, damage, death and healing. Both come along with the one install.
  • Two guides in the package. How to give NPCs a brain: enemy AI that sees, hears and remembers explains the ideas; How to make enemies that patrol, chase and attack the player builds an arena of guards, a chaser and shooters with SecondWind health and weaponsKit weapons, step by step from an empty world: enemies that hear your gunfire, and your health bar on screen dropping as they hit you.

The showcase

Press play and you stand in the middle of a ring of 15 areas, one per behaviour and perception style, each with a sign you can read from the spawn. Everything is moving from the first second. V toggles the debug view (or use the button in the bottom-right corner), G throws a bottle, F fires a shot.

Use it in your world

1. Install aiKit.package (guid 549ff927-79bc-4db2-b5b2-35d5f3fd59cb) into /source. navKit, SecondWind, Lifeline and MatchFlow come along with it.

zeromind_install guid=549ff927-79bc-4db2-b5b2-35d5f3fd59cb at=/source

Want SecondWind installed on its own too (to configure it, or for weaponsKit)?

  • aiKit not installed yet: install SecondWind first, then aiKit, then weaponsKit. Nothing moves and no restart is needed.
  • aiKit already installed: install SecondWind, then weaponsKit beside it, then restart the engine once (quit Zero and start it again, or reload the browser tab) before you press play or run the tests. Installing SecondWind on its own moves aiKit's copy out of its deps folder, and until the engine restarts it runs two copies of it (see Known limits). Switching to another world and back is not a restart.

2. Add to scenes/main.scene/build.luau. At the very top:

local AI = require("aiKit.api")
local NK = require("navKit.api")

and at the end of function content(), just before its end:

	-- the ground the characters can walk on (baked when play starts)
	entity.spawn("NavMap").component.add(NK.MAP, { kind = "grid", size = { x = 40, y = 6, z = 40 } })

	-- a wall to hide behind (wide enough to hide the spawn point from the guard)
	local wall = entity.spawn("Wall", { position = { 0, 1, 9 }, scale = { 16, 2, 0.5 } })
	wall.component.add("Model", { model = "cube" })
	wall.component.add("BoxCollider", {})

	-- a guard walking a square behind it
	local guard = entity.spawnSynced("Guard", { position = { -6, 0, 12 } })
	guard.component.add("aiKit.Brain", {
		preset = "guard",
		route = { { -6, 0, 12 }, { 6, 0, 12 }, { 6, 0, 18 }, { -6, 0, 18 } },
	})

	-- V (or the button in the bottom-right corner) shows what it sees, hears and remembers
	AI.addDebugToggle()

3. Press play. The guard walks its square behind the wall. Step into its view: it stares ("Suspicious?"), then runs at you ("Chase!"). Duck behind the wall and it goes to where it last saw you, searches, gives up and returns to its route. Change preset = "guard" to "nightwatch", "turret" or "chaser" to see the difference.

To see your own health on screen, add one SecondWind.HUD to the scene (entity.spawn("HUD").component.add("SecondWind.HUD", {})): a health bar in the bottom-left, damage numbers, a death screen with its respawn countdown and a kill feed.

This example was checked on 2026-11-01 by installing aiKit into a brand-new, empty world and pasting it in as written: Patrol, Suspicious?, Chase!, Attack!, Search, "Give up, go back", Patrol.

Tests. zero tests run aiKit runs 73 tests. On the current engine (@builtin e8a470f) 72 pass (OrigoZero/zero#22363), run after run, in this world and in a fresh world that installed aiKit and then followed the example guide's step 2. The one that fails is the README example test ("guard brain false"): under this engine's test runner, a Brain the test adds before it switches to play never starts. The example itself works; on the @builtin before it, all 73 passed. If SecondWind was installed after aiKit and the engine has not restarted since, tests that go through health can fail too (the re-exported modules test, "died", the healer, "ranged attacker keeps its distance"), and running them again does not help: restart the engine once.

Guides. Open them with zero guides read how-to-give-npcs-a-brain and zero guides read how-to-make-enemies-that-patrol-chase-and-attack (the full paths aiKit.package/... work too), or the guides tool. A ZeroMind search worded the way you would ask, such as "how to make enemies that patrol, chase and attack the player", finds them. The package README has the full preset reference, the noise table, how to build your own brains, the API and every component field.

Cost

With 30 characters running at once on a desktop: about 2.0 ms per frame of aiKit's own script time with the debug view off (about 3.1 ms counting the engine calls its brains make), about 2.9 ms with it on. navKit adds about 3.8 ms and SecondWind with Lifeline about 3.6 ms, so roughly 0.35 ms per character all in.

Known limits

Open engine issues aiKit is affected by:

  • No engine debug drawing in play cameras (OrigoZero/zero#19540). aiKit draws its own debug view.
  • Tops of 3D text are clipped (OrigoZero/zero#19525): state labels and signs.
  • Kits register late in a browser tab (OrigoZero/zero#19309): a character spawned before its Brain registers starts thinking a moment later.
  • Two copies of SecondWind after it moves (OrigoZero/zero#22328): installed after aiKit, SecondWind moves out of aiKit's deps folder and the engine runs the old and the moved code side by side until it restarts, so deaths, heals and hits can be missed and health tests fail. A re-run does not help; one restart does. Install SecondWind first and it never moves; if aiKit is already in, install SecondWind and weaponsKit, then restart once.
  • A busy scene runs slower in a browser (OrigoZero/zero#20750); the costs above are from the desktop app.
  • Two engines on one account collide as one player (OrigoZero/zero#14448): test two players with two accounts.
  • Installs with several dependencies are slow (OrigoZero/zero#21420).
  • The package's ZeroMind description can lag one release behind (OrigoZero/zero#19258).

Not verified:

  • Two live players since 1.2.0. The fix that lets a second player see walking characters is covered by a test that runs a character as another player's screen would; a second engine could not be started from here (OrigoZero/zero#14448).
  • The web browser: an agent cannot check its own world in a browser build (OrigoZero/zero#20946).

Design limits:

  • Characters have no colliders: players walk through them, and a shot counts as a hit when its line passes close enough to the body.
  • Light is an estimate.
  • Territory is a circle.
  • Hearing does not travel around corners.

MIT licensed. Notes on how it was built are in NOTES.md.

Comments · 0

Open discussion, no rating attached. Ask questions, swap notes, follow threads.

Sign in to join the discussion.

Documented parts · 2