3
\$\begingroup\$

I'm working on a multiplayer game, and I've implemented a simple enough player prediction (according to this great article) - which works well enough.

What isn't discussed there, and my question here; is how do I handle non-raycast projectiles (like missiles for example)?

There is RTT between the player pressing fire to the time he receives back the server's "confirmation", and then all other players add their latency to the mix.

And of course there is the issue of actually rendering hits; what if I see my missile hit someone in my simulation while he wasn't even there on the server and the missile missed him completely?

So my question is, what is the best way to hide latency for all players in (relatively) slow moving projectiles in an authoritative server?

\$\endgroup\$
  • \$\begingroup\$ I could do with an answer to this. As it is, I get the server to send the client a batch of "unfired" bullets, which the client can launch immediately. However, since the server is authoritiaitve, only hits validated by the server actually do any harm. \$\endgroup\$ – Steve Smith Aug 30 '18 at 15:24
2
\$\begingroup\$

This is what we ended up doing:

Client side

  1. Detect player clicks button to shot missile
  2. Immediatley simulate rocket visuals on client
  3. In parallel, send command to server
  4. Once predict hit something, destroy missile (no explosion)

Server Side

  1. Receive fire command
  2. Save client ping data on missile
  3. Fire missile, each frame accelerating the missile until we've caught up with the lag delta (but without rewind replay)
  4. On explosion, send both explosion FX + damage result

It works very well most of the time (around 99.9% of the time)

\$\endgroup\$
  • \$\begingroup\$ What about other clients? Did you spawn local bullets for other clients (if so how you handled them?) or server manages/sends movement of bullets and other players just receive/interpolate? \$\endgroup\$ – unlut Aug 9 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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