Arqade is a question and answer site for passionate videogamers on all platforms. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I looked at these videos:

I don't understand this. Why are the engines compensating for bullet speed by putting the hitboxes in front of the characters?

It looks like the engine calculates the bullet trajectory using infinite speed, and then compensating for bullet speed by moving the hitboxes in front of character.

Isn't it better to have the bullet have a real speed, and then always have the hitbox on top of the character model? That would also allow for different weapons to have different speeds, and also have correct speed based on distance.

share|improve this question

closed as off-topic by Frank, Kareen, Dallium, pinckerman, kalina Dec 15 '15 at 13:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about Game Design and Development are off topic. This includes speculative questions about developer intent, with respect to both mechanics and narrative. You might want to ask over at GameDev.SE, but be sure to read their FAQ" – Frank, Kareen, Dallium, pinckerman, kalina

they are not compensating for bullet speed. they are compensating for lag seeing these are both online games – Serge Bekenkamp Sep 4 '12 at 0:36

This is a topic called "lag compensation" and it is one critical aspect of network-based gaming, especially in shooters. The best article about this that I've read is on the Valve Developer Wiki, but I'll attempt to summarize in some simpler terms.

When you're playing a game with other players on a network, you are essentially sending a series of commands to a server, and that server is responding back with the results. Everyone is doing this at the same time. That means that there is a really good chance that what you are seeing on your screen is at least a little out of date - usually at least tens or hundreds of milliseconds out of date.

That means that when you line up and take a shot at someone, you're doing so based on some old information. You're shooting at where that person was the last time the server told you this information. They've probably moved since then. You send a command to the server saying "hey, I'm aimed at this guy, and I pull the trigger. BAM! I hit him!"

When this command gets to the server though, it already has a command from the other player that says "I sidestep to the left 5 feet." If the server took both of your commands, you'd miss, even though on your computer you saw a hit.

The game has to compensate for this, and there are a couple of big ways that this is done. One is that your client assumes certain things complete, even though the server hasn't confirmed they've happened. This is called client prediction. If you've ever gotten really bad lag where you take a couple of steps forward but then snap back to your old spot, this is client prediction gone bad.

What you're seeing here, though, is called lag compensation. Essentially, the server gets your command to shoot the other player, and it rewinds the game to the point where it was when you sent it to the server. From there, the server attempts to determine if you hit the player or not. That is to say, even if they'd moved in the time it took your command to get to the server, you still executed the "shoot" command before the other player sent his move command, and so it counts as a hit.

The net effect of this is that hitboxes are going to appear weird depending on where you're looking at them - the client is thinking slightly ahead, and the server has to continually rewind time.

To your question about bullet speed, many weapons in FPS games are "hitscan" weapons, which means that when fired, it is assumed their projectiles are infinitely fast and impact whatever they were fired at immediately. Most bullet-type weapons in TF2 are this way, for instance.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.