Spielerando

Check who is inside a sword swing, even when facing left

A swing that covers a wedge in front of the hero works when facing right and strangely misses enemies when facing left. The cause is a wrap-around in angles. This entry shows the right way to compare directions and what to do with an enemy standing right on the hero.

Why this works

Directions form a circle, not a line, so two directions that are almost the same can look far apart when you subtract them. Always measure the shorter way round, and a swing works the same whichever way the hero is facing.

When not to use it

Skip it for attacks that hit everything around the hero, or a whole line, where direction does not matter. A plain distance check is enough there. For very wide swings that curve, check against the blade's real shape instead.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 25 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 "Check who is inside a sword swing, even when facing left" (read_entry sword-arc-hit-across-the-turn-point) 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