Hitscan

Hitscan in video game design, most commonly in first-person shooters, is a type of hit registration system that determines whether an object has been hit or not simply by scanning if the item used was aimed directly at its target and then applies the effects of the item (usually damage) instantly. A weapon, for example, does not launch a projectile the player needs to lead, damage is applied as soon as the player's crosshair is on a target and the fire button is pressed. Internally, this is most commonly done by simulating a ray from the origin of the item along the trajectory of the "projectile" and simply scanning for any objects touching the ray. Games might still show a visual of a projectile although it technically has no effect. In contrast, a projectile-based weapon would launch an actual projectile object that moves through the virtual space at a certain speed and will apply damage only once it has actually touched ("hit") a target.

A projectile weapon which uses unmodified hitscan information to dictate whether or not it has hit its target is often called a hitscan weapon. Shooting the weapon calls the hitscan function, and if an object is detected in the projectile's path, a hit is registered. Once it's determined if something was hit or not, the system will then give a damage output based on where the ray hit the object. Since the effect is immediate, the projectiles effectively travel at infinite speed and have a linear or otherwise simple trajectory—a practical approximation of a bullet's speed and accuracy over short distances.

The hitscan method is modifiable by making some surfaces reflective, making the hitscan rays go on forever with no stop, or able to penetrate multiple objects at the same time in the same line. To improve the realism, programmers may use hitscan functions in slightly different ways; for example, applying a random perturbation to the calculated path to simulate inaccuracy.[1][self-published source] A simplified version of this occurs in the first-person shooter DOOM; when the player holds down the fire button with the pistol, it fires inaccurately from the second shot. As another example, the submachine gun in Half-Life 2 calls a hitscan function in the middle of a 'blazing gun' animation, creating a small amount of lag between weapon deployment and the hitting of the target to better approximate real-life ballistics.

  1. ^ Jung, Tristan (2018-07-14). "How Do Bullets Work in Video Games? - Tristan Jung". Medium. Retrieved 2019-07-18.[user-generated source]