How do multiplayer shooter video games track bullets. In games like Battlefield thousands of “bullets” can be fired in a round. How does the game know who fired what and who hit/killed who?

211 views

[ad_1]

How do multiplayer shooter video games track bullets. In games like Battlefield thousands of “bullets” can be fired in a round. How does the game know who fired what and who hit/killed who?

In: Technology
[ad_2]

A bullet is an entity, storing the ID of the player who fired it and the direction of the bullet, maybe also what weapon fired it, the speed and the damage depending on the game

It’s programmed to move until it finds another player or the ground and if it hits a player, damage is applied and since it knows who fired it you can do What You need to do.

Another even simpler way that is used is to, when a player presses the trigger, look for all players in a straight line form the muzzle and damage the first one, since it’s instant, there is only one player that can shoot in that instant and you don’t need to store the player who shot it or anything, but this is falling out of use because it’s less accurate

1. You aim, pull trigger
2. Your game says to game server, he pulled trigger, aiming *here*.
3. Game server does some math, figures out what you hit, sends message back to your game.
4. Your game shows your enemy’s head exploding (or not).
5. Meanwhile, if you blew his ass up, game server sends, “YO ASS GOT SHOT!” message to that guy. Or maybe just “YUO DEAD, BRO!”
6. This usually happens about 10 times a second, maybe more depending on the game.

How does it keep track of everything? It keeps a lot of lists and updates them really fast.

This is basically a weird way of asking “how do computers work” or “How do games work”.

Everything that exists inside a game is it’s own entity, or game object.

When a bullet is fired, that bullet is an entity that exists in the game, and holds a ton of information.

Information including what the ID of that bullet is (for example, ID 2887), who shot it, how fast it’s travelling, what direction it’s going in, is it effected by gravity, how much damage will it cause, how far can it travel before being deleted, etc etc etc. It just holds a list of everything it needs to know, and does some maths to work out where it’s travelling.

A server is powerful enough to hold all of this information, for every bullet that ever exists in a game, 10000 times a second.

Each player has their own “Player ID” of some form, so when a bullet hits another player, the sever is basically saying “bullet entity 2887, from Player ID 180837, collided with Player ID 788973”.

“Reduce player ID 788973’s Health points by Bullet 2887’s damage output”.

Many shooter games don’t even track bullets. They just see what you’re looking at when you click the mouse to fire a bullet. Then they do damage to that thing. At no point does the game actually create a bullet. It’s just “click to do damage”