2
\$\begingroup\$

I'm thinking about an algorithm for firing projectiles with lag compensation. Now I did find only one descent solution:

  1. Player hits fire button.
  2. Client sends input "fire".
  3. Client waits for server response.
  4. Server generates bullet then sends response to client.
  5. Client recieves response and finally fires projectile.

Is this solution only "trueway"? I find it the only one that can be fair to all of the clients. Valve in this case, doesn't compensate lag from rocket shots. I am feeling that I will not compensate it, too. I think that with today's bandwidth I can close my eyes on this problem, because I don't see any solutions with fair logic. What do you think?

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

Since you mention bullets...

  1. player hits fire
  2. player immediately draws something
  3. client sends command to server
  4. server gets fire command
  5. server calculates the results, hit or miss
  6. server sends result to player
  7. player applies the result from the server
  8. player draws something to show the result

There is no physical "bullet" flying around, just a phantom drawn locally. You cannot wait 200msec for for server responses or your game will feel sluggish.

Rockets are a totally different subject: they are expected to have an "ignition time" before flying off, they move slowly, they have an area-effect when they hit, some have a small AI guiding them during flight. Bullets are not rocket science.

\$\endgroup\$
11
  • \$\begingroup\$ I need projectiles with life time and flying time, and i will not have rockets, players will shoot projectiles, like small fireballs, frozen arrows, etc. How i have to manage networking with projectiles? \$\endgroup\$ Mar 2, 2012 at 19:09
  • \$\begingroup\$ Actually not all games use this approach. The sluggish feel is not true for every FPS. Unreal Tournament 2004 and 3 waits for the server respond before shooting. Not only for rockets, but every weapon, including shock rifle. \$\endgroup\$ Mar 2, 2012 at 19:26
  • \$\begingroup\$ Yeah i feel like i just dont need to make any prediction system for projectiles and spells, just wait for server response \$\endgroup\$ Mar 2, 2012 at 19:29
  • \$\begingroup\$ You need prediction if there is latency. Otherwise, you're asking for a laggy game. There is nothing worse than hitting the "fire" button, and having a delay. Keep in mind that a 1/4 second delay is unacceptable, even if it seems like a very quick amount of time. \$\endgroup\$
    – Tim Holt
    Mar 2, 2012 at 20:27
  • \$\begingroup\$ And how i need to predict flying projectile and be fair to players? \$\endgroup\$ Mar 2, 2012 at 20:29

You must log in to answer this question.

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