Spielerando

Show where a hit came from and keep the arrow right when the player turns

A red arrow at the screen edge tells a player who shot them. If it is computed once, it points wrong as soon as they turn, and several hits from the same side pile up into a mess. This entry shows how to keep it true and tidy, including across the back of the player.

Why this works

The arrow answers the question where, from where the player looks now. The attacker's place in the world does not change when the player turns, but the answer on the screen does, so the arrow has to be worked out again every frame, not stored.

When not to use it

Skip it for games with a fixed top-down view where the player never turns, or where hits come from everywhere at once. A screen flash or a sound cue then says "you were hit" without a direction that cannot be read.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • 28 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 "Show where a hit came from and keep the arrow right when the player turns" (read_entry damage-direction-arrows-follow-turning) 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