← all posts site ↗

horror game killer ai design

building a horror game where a killer with a bow hunts you across a campus. the core loop is cat and mouse — you run, he shoots arrows in parabolic arcs when far away and straight shots when close. one hit kills you. falling from heights stuns you. you can sprint, slide under obstacles, vault barriers, climb pipes to the roof, hide in buildings. arrows that miss can be scavenged but pulling them out takes a few seconds of animation lock where you're vulnerable. the killer feels like mr x from resident evil — unstoppable, always coming, nothing stops him. but it felt hollow because all you do is run away with no agency beyond foot speed.

the fix is making the killer's teleportation predictive instead of reactive. when line of sight breaks he doesn't just spawn somewhere random. he calculates a lead time based on your velocity and heading, then spawns at a predicted position ahead of you. early in the game the prediction is weak — he teleports to where you were ten seconds ago, giving you a false sense of security. mid game he predicts eight seconds ahead, spawning on the roof before you climb the pipe, or at the midpoint of the bridge you're running toward. late game he spawns at chokepoints — the top of stairs, the end of narrow hallways, the only window you can jump through — so the map itself feels like it's fighting you. this creates near misses where you arrive at a location just as he materializes, forcing last-second slides or jumps.

to keep spawns from breaking immersion the ai validates every teleport target against the navmesh, checks that it's not too close to the player, and ensures there's no line of sight so he never materializes in your direct view. he always spawns behind a wall or around a corner. the search radius tightens based on player behavior — if you stand still for a long time the killer spawns closer, maybe eight meters away on the same floor. if you're moving it predicts further ahead. height delta checks prevent him from spawning in the sky or underground or outside the campus bounds. the result is that whiplash feeling where off-screen he's a teleporting force of nature but on-screen he's just a man slowly walking toward you stalking and staring. you never know which version you're getting until you look.