First of all: Sorry if I don't express myself very well, I'm not very fluent in english :'(
I'm developing a multiplayer tile-based game (imagine habbo) and having some trouble with the movement. The idea is to click on a tile (target tile) so your avatar moves there and everyone can see you moving there. In order to do that, there's a pathfinding function.
My first approach was to run the pathfinding function in the client and everytime the avatar moved a pixel (guided by the pathfinder), the client sent a message to the server which broadcasted this update. This was obviously crazy...
My second approach was to send to the server just the target tile. The server broadcasted this target tile, and each client ran the pathfinding function for each avatar in movement. I found problems with this because of synchronization: imagine two users moving that pass through the same tile at different times, maybe in one client with a little lag it happens that they pass through the same tile at the same time, so the pathfinder will stop one of them, as you can't walk over another avatar. This would lead to different positions in each client.
I've read some cases where the pathfinder runs in the server, the client just send the target tile and receives every x mseconds an update from the server with the pathfinding calculations for every avatar in movement (even himself). The problem I find here is how to set this "x mseconds" and that it might mean a lot of load to the server, handling all the pathfinding calculations...
So, has anyone deal with this problem? What would you do?
Thanks a lot, Carlos
Edited by cnavast, 02 June 2013 - 11:17 AM.