← All interactive demos

How Bullets Hit — Interactive Demo

From the video "Hitscan vs. Projectile Weapons: What's the Difference?". A simplified 2D model seen from above (no gravity and no network delay).

Field from above (16×6 squares, 60 frames = 1 second) — you can also click / tap the field to fire

Frames to the aimed point: - Result - (counts for this scene and this speed; time is not measured)
Task: Turn on the "Thin wall", set the bullet speed to 1.0 squares per frame or more, and fire so the bullet passes through on purpose. When it does, switch to "Segment check" and confirm that the bullet hits the wall at the same speed. Then remove the wall, raise the target speed, and switch "Lead the target" on and off to see how far you can still hit.

What it does: the "line gun" calculates, at the moment you fire, where the line from the muzzle in the aimed direction crosses the target's circle and the wall's rectangle, and counts the nearest one as the hit (0 frames). The "bullet gun" moves the bullet by "bullet speed × 1 frame" every frame. The point check tests whether the bullet's point is inside the circle or rectangle. The segment check tests whether the line joining the previous frame and the current frame crosses the circle or rectangle. "Lead the target" estimates the frames needed to reach the target as distance ÷ distance per frame, predicts that the target keeps moving in its current direction at the same speed, and aims at the point target speed × frames ahead (the estimate is redone twice; it does not know about turning back, so it misses if the target changes direction on the way). The target moves up and down. The aim is the target's position at the moment you press "Fire" (or the point ahead, if leading is on).
AI was used to make the diagrams and code. No game footage is used. Sources are in the video description.