Projectile aiming and spread
Aim where the target will be, not where it is.
Bullets take time to arrive, so shooting at a moving target misses behind it. Leading the target means solving for where it will be when the shot gets there. Spread is the opposite tool: a random angle inside a cone that makes guns feel loose or tight, and it should be shaped, not pure noise.
Try this: Fire at the moving slime with lead off: shots land behind it. Turn lead on (L), then try wider spread.
Fire at the slime.
Prompt bit
Works for 2D or 3D in any engine (Unity, Unreal, Godot, web). Paste the short one for a quick fix, or the detailed one when you want it done properly.
Aim projectiles with target leading: solve for the intercept time when a shot at constant speed meets the target's current velocity (usually under 1 s), aim at that point, add spread inside a cone, and fall back to direct aim when no solution exists.
Add lead aiming and spread to enemy and turret projectiles (2D or 3D, any engine). Given shooter position S, target position P and velocity V, and projectile speed s, solve |P + V t - S| = s t for the smallest positive t (a quadratic: a = V.V - s^2, b = 2 V.(P - S), c = |P - S|^2). If there is no positive real root (target faster than the projectile and moving away), aim directly at P. Aim at P + V t. For gravity arcs, solve the launch angle instead or iterate. Then apply spread: pick an angle within a cone (default 2 to 6 degrees), biased toward the centre (average two randoms) rather than uniform. For players, make spread grow while moving or firing continuously and recover over about 0.3 s. Give enemies an accuracy setting that blends between direct aim and full lead so they are beatable. Draw the predicted point in debug mode.
Where it's used
- Shooters: turrets and enemies leading moving players
- Tower defence: towers hitting fast creeps
- Space games: lead indicators for the player
- Shotguns and SMGs: spread cones and recoil bloom
- Sports games: passing to a running teammate
Common mistakes
Aiming at the current position so every shot trails behind, perfect lead that is impossible to dodge, uniform random spread that feels noisy, and ignoring the no-solution case so turrets aim at NaN.
Writing this with an AI assistant? See our best AI coding assistants for game developers.
Missing a concept? Request one.



