UE5 Behaviour Tree design for deer NPC — Sunflower, 2024
The Problem
What I was trying to build
Sunflower needed wildlife NPCs that felt alive — deer that reacted to the player's proximity, fled when startled, and returned to idle grazing. I designed a behaviour tree to handle these states in UE5. The prototype worked in isolation but broke down when debugging in-game, and time constraints meant it was cut before shipping.
What I Built
What I built and where it failed
- Behaviour tree design — three-state tree: Idle (grazing), Alert (player detected), Flee (running away from player)
- Perception component — UE5 AI Perception configured to detect the player via sight with configurable radius and angle
- The failure point — deer flee direction was calculated incorrectly, causing NPCs to run toward the player; debugging the vector math in Blueprint was slow and the root cause wasn't resolved in jam time
- What I would do differently — isolate vector logic in a test map before integrating into the behaviour tree; use UE5's visual AI debugger from day one rather than print strings
Reflection
Why documenting failure matters
Documenting a scrapped feature is uncomfortable, but it reflects real production. More importantly, I now understand UE5's AI Perception and Behaviour Tree systems well enough to implement this correctly — and I know exactly where my knowledge gap was and how to close it.
Research Question
How should NPC behaviour systems be designed for debuggability — not just correctness — and what tooling would make AI logic in game engines more transparent during development?