Unity NPC behavior
Designs understandable Unity NPC behavior with explicit knowledge, priorities and interruption rules. Uses the simplest suitable decision model and avoids enemies tracking information they never observed.
unity-npc-behavior
Agents using this skill
When is it useful?
Use it when designing patrol, combat or difficulty behavior without adding a larger AI framework than the mechanic needs.
What does it help you do?
- Chooses the smallest suitable decision model for the mechanic.
- Defines guards, priorities, interruption, target validity and cooldowns.
- Separates sensed knowledge from execution without omniscient tracking.
Try asking this
Build a Unity guard that patrols, investigates a noise and searches after losing sight of the player. Define how long its last-known-position memory lasts and when an attack can interrupt searching. Test hiding behind cover and destroying the target; the guard must return to a valid action without knowing the player's unseen location.
Detailed documentation
Read the skill’s original instructions, examples and checks in their authored language.
Show less
NPC Decisions and Behavior
Choose the smallest decision model
Read project instructions, Unity/package versions, existing NPC code, movement/animation authority and networking rules. Define player-facing scenarios and what each NPC may know. Reuse the current architecture unless the task calls for replacing it. A small FSM is often sufficient; use behavior trees, utility scoring or planning when the actual decision complexity warrants them.
Decision contracts
- Separate perception and memory from decision making, action execution, steering and locomotion. Actions consume known facts and issue motor commands instead of directly competing with the movement controller.
- Specify states/actions, entry and exit behavior, guards, priorities, interruption, cooldowns and failure results. A task that never completes or cancels can stall an entire behavior tree.
- For utility decisions, document considerations, normalization, invalid choices, tie handling and fallback. Add hysteresis/commitment where needed so small score changes do not cause rapid oscillation.
- Give targets explicit validity and memory expiry. Handle death, despawn, pooling, scene changes and stale references. Cancellation must release reservations, subscriptions and motor commands.
- Define fairness: reaction delay, line of sight, hearing, last-known position, attack telegraphs and permitted shared knowledge. Do not silently grant omniscient player tracking.
- Bound decision frequency and expensive work. Check the intended crowd size and avoid synchronized spikes; optimize from traces, not assumptions.
- Unity Behavior and other frameworks are optional dependencies. Check the installed version before choosing graph APIs; do not claim a graph exists or hand-edit its serialized representation without verified tooling.
Verify and explain
Expose current state/action, transition reason, known target, memory age and relevant scores. Exercise idle/patrol, detection, pursuit, attack, target loss, interrupted action and recovery. Use controlled randomness for reproduction; do not claim fairness or believability from compilation alone.
References: version-matched Unity Behavior, Craig Reynolds's action-selection/steering/locomotion model and Dave Mark's utility architecture overview. These are design references, not required libraries. Inspect relevant official Unity agent skills before proposing additional tools. LLM inference or ML training is a separate explicitly authorized feature, not a prerequisite for NPC AI.
Included files 1
SKILL.md
