Spielerando

Make a shooter walk to a spot where it can actually hit the player

The enemy walks right up to the player, or stops at the wall and fires into stone. Here is how to look for the nearest place that is both close enough and in clear view, and why distance in a straight line is the wrong measure for the walk.

Why this works

A shooter needs three things at once: a spot it can walk to, close enough to hit, and with a clear line of sight. Searching outward step by step finds the nearest spot that has all three, while the straight line only finds the wall in between.

When not to use it

Skip it for enemies that shoot through walls, lob things over them or fire from anywhere on screen. They have no sight to keep, so any spot in range will do. It is also wasted work if the target moves faster than the shooter can reposition.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 50 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 "Make a shooter walk to a spot where it can actually hit the player" (read_entry find-a-firing-spot-in-range) 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