3
\$\begingroup\$

I play a lot of "Call of Duty", and can see tracers for gunfire, missiles, care packages falling from helicopters etc. There is a lot of activity. I am curious to know the algorithm one would use, at a high level, to manage all this action when you have 20 people on a map shooting each other to death.

This question touches on the subject, but doesn't ask for a more in-depth answer as to how you the developers go about calculating and transmitting movement and collision detection for projectiles, be it missles, bullets, or any other object that is flying through the air in real-time.

How are trajectories calculated and transmitted to other players, in multiplayer?

\$\endgroup\$

1 Answer 1

7
\$\begingroup\$

It depends on how important object for gameplay and how it working.

Generally projectiles like missles move along a predictible trajectory so server can spawn a new object, set its position, direction, speed and transmit data about new projectile to clients. Client-side code will simulate movements of a projectile using this data. If projectile hit something important (world geometry, other player or something else) server process this and inform clients about this.

Human controlled objects require different approach. Since it cannot be fully predicted on client-side, server frequently send updates about position and direction to clients. Often this data include speed of object to allow client to interpolate and/or extrapolate movements of object between updates from server.

\$\endgroup\$
3
  • \$\begingroup\$ Ahh.. so you just transmit starting point and trajectory to all co-op players that need to see it. The local console just renders based on that instruction. So, what if the effect cannot be seen in the players viewport, but could be heard, would that be a different transmission to render sound depending on distance from the effect? Or would it just get calculated by the console getting the transmission about the bullet/missile and then determining that you can't see it but you need to hear it ? \$\endgroup\$
    – angryITguy
    Jun 15, 2011 at 5:57
  • 2
    \$\begingroup\$ @giulio: The server would need to be aware of the proximity for sounds (such as explosions), and inform all clients within that proximity. Based on distance, the client can calculate the appropriate volume level to use when generating the sound for the explosion. \$\endgroup\$ Jun 15, 2011 at 7:00
  • \$\begingroup\$ @giulio: The trajectory is usually transmitted to all players (whether they see it or not), because it is usually client's responsibility to calculate visibility (as it would require too much resources from the server). The obvious weakness in this is that all kinds of wall hacks are possible. \$\endgroup\$
    – Cloudanger
    Jun 20, 2011 at 13:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .