Spielerando

An enemy chases the player across the whole level and never goes home

A guard should chase for a while and then give up, walk back to its post and wait. Done carelessly, it turns around at the edge of its zone, sees the player again and runs back out, forever. Here is the rule that stops that, and which distance to use.

Why this works

A guard that wakes and sleeps at the same line will turn at that line, see the player again and run back out. Waking at a near line and giving up at a farther one leaves a gap that settles the matter, and counting the walk keeps walls in the picture.

When not to use it

Don't leash enemies that are meant to hunt without end, such as a stalker or a boss in a chase level, or those that guard a place nobody can leave. Let them follow, and give the player an escape like a door instead.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • A diagram of every state
  • 29 lines of example code with 5 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "An enemy chases the player across the whole level and never goes home" (read_entry enemy-leash-by-walking-distance) in my game. Build it step by step, and show me how you checked that it works.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP