Spielerando

Wandering enemies pile up at the ends of their platform

An enemy that takes random steps along a ledge should spend about as much time in the middle as at the edges. The common fix of cutting the position off at the border makes them stand at the border far too often. There is a way to turn at the edge that keeps them evenly spread.

Why this works

A wall should turn a walker around, not hold it. Cutting off the overshoot leaves the walker standing on the border, while folding the overshoot back, like a ball off a cushion, keeps it moving and spreads its time evenly along the whole path.

When not to use it

Skip it when enemies should have a reason to stop at edges, such as guards who look around at the end of their route. Pure random steps then look aimless. Use a patrol with set stops and a pause at each end.

In the full entry

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

Say this to your AI

Use the Spielerando entry "Wandering enemies pile up at the ends of their platform" (read_entry patrol-wander-reflects-at-edges-instead-of-sticking) 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