Spielerando

Knock a creature back by exactly the distance you chose, at any frame rate

A shove that multiplies the speed by a number each frame throws the creature twice as far on a slow computer, and a hit against a wall can leave it stuck in it. Here is how to choose how far and how long it slides and have both come out right every time.

Why this works

Sliding to a stop under rubbing follows a fixed curve, so how far the thing goes depends only on the push and the rubbing, not on how often the screen redraws. Choosing the distance first and working backward gives the designer control that a per-frame fudge never does.

When not to use it

Don't use it when the hit should launch the creature into the air, over a gap or into other creatures that must be shoved in turn. Those need real movement with collisions along the way, not a path fixed at the start.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 35 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 "Knock a creature back by exactly the distance you chose, at any frame rate" (read_entry knockback-covers-the-planned-distance) 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