Shots always miss a moving target because they aim where it was
The turret fires straight at the player and the bullet arrives behind them every time. Here is how to work out the point where bullet and target meet, what to do when the target outruns the bullet, and the case where there is no answer at all.
Why this works
A bullet takes time to fly, and in that time a moving target is somewhere else. Aim at the spot where both will be at the same moment, which you can work out from their speeds, instead of at the place the target has already left.
When not to use it
Don't lead the shot at targets that turn, stop or dodge all the time, since the guess is built on a straight path and misses wildly. Aim straight, fire spreads or use a homing shot. Perfect aim can also feel unfair, so add a little error.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- 23 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 "Shots always miss a moving target because they aim where it was" (read_entry aim-at-where-the-target-will-be) 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