Spielerando

Make a sword swing hit each enemy once, not every frame

The sword touches an enemy for a few frames and the enemy loses all its health in one swing, or the hit never lands because it was checked at the wrong moment. Here is how to tell the game which frames count and who has already been hit.

Why this works

A swing is one act, even though the weapon overlaps an enemy for many frames. Giving each swing a memory of whom it has touched makes the damage follow the player's idea of one hit, and resetting it with each swing keeps later swings working.

When not to use it

Do not limit hits when the weapon is meant to hurt over time, such as flames, a saw blade or a beam. There the damage should tick at a steady rate while contact lasts, rather than land once.

In the full entry

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

Say this to your AI

Use the Spielerando entry "Make a sword swing hit each enemy once, not every frame" (read_entry one-hit-per-swing-per-enemy) 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