---
name: ferret-micromotion
description: Use to keep idle people alive in Ferret (@ferret/micromotion): a profile and a seed give a person who gestures, looks about, fidgets, walks about his place, speaks with beats and reacts to blasts and impacts; levels of detail, clips as masked layers, micro.* commands and the ?micro viewer.
---

# Idle people

## When to use
People of a scene who are not the player and not in a scripted animation, and who must never stand like posts: bystanders, a crowd that waits, someone who sits and watches, someone who holds a camera or a prop. Not for the player's own movement (`ferret-character`), not for walking by a NavMesh (`ferret-ai-navigation`, which the module only hands over to), not for making the figure (`ferret-humans`).

## The model
A person is a profile (JSON: temperament, repertoire, props, anchors, interests, reactions) and a seed. `sim` is pure numbers in the fixed step and decides everything (activities, gaze, blinks, walks, reactions); `applyMicro` puts the result onto a humans rig pose in the frame. The same seed gives the same choices on every peer and in the UE build.

## Steps
1. `const micro = new MicroSession()`; `micro.spawn(id, 'bystander' | yourProfile, seed, { pos, facing })` (the place becomes his anchor); `micro.setTarget({ id, pos, tags })` for what may draw his eye.
2. In `onFixedUpdate`: `micro.step(dt)`; `micro.attach(world.events)` so blasts, impacts, fires and take events reach him.
3. In `onUpdate`, per person: a base pose from a clip (`Idle`, or `Walk_Fwd` when `out.moving`), then `applyMicro(rig, pose, person.out, person.profile, { time, seed, lod, seatHeight, clips? })`; draw the pose, and give `report.face` to the face.
4. Levels: `micro.assign([{ id, px: screenHeightPx(1.8, distance, fov, screenPx) }])`, pose by `poseLevel(lod)` (`crowd` and `off` are not posed).
5. A line: `say(person, { text, duration, shout })`. A profile of your own: `validateProfile`; shipped ones: `profile('name')` returns a copy.
6. His own AI (habits: seated leg swing and head turns, standing weight shifts, blinks; rates from the temperament): `micro.mode`, `micro.habit`, `micro.temper`, `micro.do`, `micro.goto`, `micro.explain`.
7. The motion language: `linkMotion(micro, bridge)` first, then `(micro-walk who x y z)` and the other `micro-*` words and `micro:*` events (reference: the guide).
8. Far planes: `bakePerson` once at creation, then `poseOf(...)` per frame (near is live; middle and far play the loop at rest).
9. Look with the `micro.*` commands (`micro.inspect`, `micro.log {times:true}`, `micro.stimulus`) and the `?micro` viewer (`node tools/build.mjs viewer`; `micro.stage`, `micro.camera`, `micro.screenshot`, `micro.capture`).

10. In a crowd simulated elsewhere: guide section "In a simulated crowd" (bone offsets per render, relaxed hands, no cuts).

## Check afterwards
`micro.log {id, times:true}` shows a choice every few seconds and never a long gap; a stimulus gives a glance first and a reaction 0.15-0.3 s after it; two persons with one profile and different seeds never move in step; the viewer's screenshots show hands on their props and feet on the floor.

## What usually goes wrong
- `(micro-walk ...)` as an argument fails: a lasting word is a statement; `(seq (on ev ...) (wait t))` loses `ev`: add a form after `wait`.
- A person walks back to a default place: he was spawned without `pos`; give the place, it becomes his anchor.
- Everyone looks at nothing: no gaze targets; add some with tags that his `interests` name.
- Nothing reacts to a blast: it was too far (`heardStrength` falls with the square of the distance past the kind's half distance), or the person has no reaction for that kind in his table.
- The pose does nothing: the base pose is not the humans rig's, or the level is `crowd` / `off` (not posed).

## Files

- `reference/micromotion.md` — People who are never still. A profile and a seed give a person who gestures, looks about, fidgets, walks about his place and reacts to blasts and impacts; deterministic, with levels of detail, micro.* commands and the ?micro viewer.
- `reference/api-micromotion.md` — every export of `@ferret/micromotion` with signature and doc comment
- `reference/api-micromotion-2.md` — every export of `@ferret/micromotion` with signature and doc comment
