Spielerando

Give hits a push that works even when attacker and victim overlap

A push away from the attacker needs a direction, and when two bodies stand in the same spot there is none, so the victim does not move at all. Repeated hits can also add up to a launch. This entry chooses a direction every time and keeps the push the same size.

Why this works

A push needs a direction, and the usual source, the gap between two bodies, can be empty. So you decide the fallback ahead of time. Setting the new motion instead of adding to it makes every hit equal, however many arrive at once.

When not to use it

Skip it for heavy enemies or bosses that should never be moved by a hit, and for games where physics should decide the push from mass and speed. Use a flash or sound to show the hit instead, or let real collisions push.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 4 common mistakes and the fix
  • 13 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 "Give hits a push that works even when attacker and victim overlap" (read_entry action-knockback-same-position) 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