I've put together a simple simulation of a chess board with 2D physics. Really simple, just top-down colliding squares. Right now all of the simulation is on the server. This actually works surprisingly well with little chop, but of course there is significant latency. I want to also run the simulation on each client, but the more I think about it the more complicated this gets.
1. The position of each piece needs to eventually end up synced.
2. If a piece is being moved by a player, it can collide with a piece, which can collide with another piece which can collide with a fourth piece which is being moved by another player.
One common solution is to only send manipulation events to the server. Get the changes made to a piece by direct interaction from the player and send positional information about it. The problem is that if I let the server just apply those changes then the likelihood that other pieces which were collided during the course of the manipulated pieces movement would closely sync with the client simulation is very low. This would break #1 above.
So let's say I can get a list of all "awake" bodies. In this case that would be any pieces that are being affected directly or indirectly from input by the player. I would then send updates for each of those bodies to the server. The problem with this arises when two players are both indirectly affecting the same piece, as in #2 above. It's possible to receive two distinctly different updates for one piece. Maybe I could average the updates together in some way? But this would lose accuracy and I feel like there would be a lot of fighting between the client and server simulations.
The ideal is to have client prediction and have a configurable small amount of latency. I just can't see how it could be accomplished in this case. Is anybody else working on this? Suggestions? Is this impossible to do well?
WhatWhereAmIMember Since 27 Aug 2012
Offline Last Active Aug 29 2012 02:52 AM
- Group Members
- Active Posts 2
- Profile Views 315
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
WhatWhereAmI hasn't added any contacts yet.
30 Aug 2012 - 03:02