9

I am trying to come to some sort of solution to a common problem with synching projectile firing and game networking in general, but am unsure on what would be the best fit.

This is a 2D action side-scroller with several projectiles (no instant hit weapons) and already has much of the framework in place (C# XNA Framework and Lidgren library).

At this time I am thinking the architecture is going to be modeled similar to the half-life source engine. Clients will interpolate remote entities ~100ms or about 3 frames in the past (fixed step 30fps) and using client side prediction. Server has authority over the simulation. Thinking about coding the implementation with movement seems fine, but when it comes to projectiles I am unsure of how it would best work to provide the best gameplay for all players.


EXAMPLE PROBLEM:

Client A
Client B
Server

  1. Client A and B are just standing facing each other.
  2. Client B starts to fire toward A and sends input to server as usual. Server detects fire input and starts to fire weapon in its simulation while relaying the event to client A.
  3. Client A receives the message but is still interpolating client B in the past (meanwhile the projectile is now coming toward A on the server and client Bs machine).
  4. Client A's rendering finally gets to the point where B shot the projectile and starts rendering that.
  5. Client A sees it and jumps, easily clearing it on his screen. However, the projectile hits him on the server and on client Bs point of view.

This is also 2D sidescroller so everything is visible.

It seems to be a fundamental side affect of using interpolation (which I think is a must, but am open to suggestions), as even without any network latency there is inherent interpolation latency.


QUESTION:

I know it cant possibly be perfect, but are there any more or better ways that I can implement to obfuscate or ameliorate this so that it looks good/seamless, or am I missing anything obvious? The firing of the weapon does have a short animation time before the projectile is actually fired which I realize we can use that time to hide some of the latency, but the weapons are not instant fire, and any way I look at it there is always going to be this large gap with the client trying to dodge projectiles and other clients seeing their projectiles hitting them.

We can use lag compensation on the server for cases where the players are moving, but I dont think that could help this situation?

If the projectile hit causes client A's position to be altered I would have to rewind client A and replay his inputs with the new data, or if it doesnt, I have to remove the projectile from mid-air (and maybe they die), ugly either way :(.

Joshjje
  • 220
  • 4
  • 14
  • Although this is a very interesting question, it is very broad and could take several pages to answer correctly. There are thousands of ways to synchronise a client-server game, and every single one of them may work, it depends on the way your game works. – Msonic Sep 05 '12 at 15:55
  • As an aside, are you sure that this is a problem? Certainly, conceptually, it's not perfect, but if the delay is small enough, the error size is probably going to be tiny. It may be that the cases where the person A sees the missile, and manages to dodge it just-barely-in-time-on-his-machine vs just-barely-not-in-time-on-server are so small that it just isn't an issue. – Beska Sep 06 '12 at 13:46
  • @Beska yeah I realized I should have posted it there after I asked, not sure how to move it. – Joshjje Sep 06 '12 at 22:27
  • And this certainly could be a minor issue, I havent implemented it to see that, but it just seems like it would be. I am thinking now it may be better, for that at least, to not render remote players in the past, but just extrapolate them with dead reckoning. There is not a lot of data that needs to be sent back and forth over the network, everything is deterministic from the players inputs, and once weapons are fired they follow a deterministic path, etc. – Joshjje Sep 06 '12 at 22:34
  • @Beska - cross-posting is bad, let the mods migrate instead. – Kev Sep 30 '12 at 23:32

1 Answers1

3

Funny you should mention half-life, valve actually published an article about this, Latency Compensating Methods in Client

Dead-Reckoning, is a pretty generally used technique in networked games so you should be able to find some more information about this online.

Google brought me this gamasutra article which might help you as well, Dead Reckoning Latency Hiding

Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
Remco Brilstra
  • 798
  • 5
  • 13
  • Yeah that is where I got the initial framework idea from and have read most of valves articles. Thanks for the dead reckoning article for sure, I will look into that further. – Joshjje Sep 06 '12 at 22:35