How Do Bullets Work in Video Games?

1 min read Original article ↗

Tristan Jung

Press enter or click to view image in full size

Photo by rawpixel on Unsplash

FPS (first-person shooter) games have been a staple in the video game industry ever since the explosion of Wolfenstein 3D back in 1992. Since then, the genre has been evolving with graphical upgrades, huge budgets, and an eSports ecosystem. But what about its core, the shooting mechanics? How have we progressed on that front? Why do some guns feel like it’s the real thing, while others feel like toys?

“How do bullets work in video games?”

Hitscan

In the earlier days, many games relied on a technique called raycasting to render 3D environments onto 2D images (your screen). Raycasting also allows the engine to determine the first object intersected by a ray. Developers then started to question, “What if that ray originated from the muzzle of a gun to mimic a bullet?” With this idea, hitscan was born.

An example of raycasting

In most implementations of a hitscan weapon, when the player shoots a bullet, the physics engine will:

  • Figure out the direction the gun is pointing at,
  • Cast a ray from the muzzle of the gun until a defined range,
  • Use raycasting to determine…