Part 1 — patrol/chase NPC and follow AI
Part 1
Patrol, chase, and follow
- Patrol and chase NPC — NPC walks a defined patrol path; switches to chase behaviour when the player enters its perception range using UE5 AI Perception
- Modular follow AI — a second NPC designed to follow any target character, with the target assignable in the Unreal details panel — no code changes needed
- Implementation — Blackboard keys drive state transitions between patrol, alert, and chase; Behaviour Tree handles task execution at each state
Part 2 — day/night AI, stamina scaling, teleporting NPC, and day/night cycle widget
Part 2
Difficulty scaling and state-driven AI
- Day/night state NPC — NPC aggressively chases the player during daytime; becomes passive and idles at night; state driven by a global day/night timer
- Stamina-scaling difficulty — player has a stamina limit; once depleted she drops to walking speed, making the NPC progressively harder to escape — difficulty that builds naturally over time
- Teleporting NPC — NPC teleports to the left of the player and resumes following; creates an unpredictable threat that can't be simply outrun
- Day/night cycle widget — UI timer widget displaying time of day; sun position in the scene updates to match the cycle state
Reflection
What this taught me
Building each NPC as an isolated, incrementally more complex system taught me how to think in behaviour states before writing a single node. The stamina-scaling NPC in particular showed me how player-side constraints can create difficulty more elegantly than just increasing NPC speed.
Research Question
How can NPC difficulty scaling be designed to feel fair and readable to the player — and what is the role of environmental and player-state constraints versus raw NPC capability in creating tension?