Make archers and towers aim where a moving enemy will be, not where it is
Arrows aimed at the place where a runner stands now always land behind him, so he looks invincible, while a perfect aim at everything looks unfair. This entry shows how to find the aim point for a moving target, what to do when the target is too fast, and how the body should turn towards that point and not towards the enemy.
Why this works
An arrow takes time to arrive, and the target keeps moving meanwhile. So aim at the spot where both will meet: the place the target reaches just as the arrow does. The lead should be capped, because a target that turns sharply makes a far-ahead guess wrong.
When not to use it
Wrong for slow, homing or area weapons, and for games meant to feel fair to dodge: if the player must be able to outrun a tower by moving sideways, perfect aim makes that impossible. Aim at the target's current spot, with some spread.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 36 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 "Make archers and towers aim where a moving enemy will be, not where it is" (read_entry tower-archer-aims-ahead-of-a-moving-target) 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