Jump to content
  • Advertisement

Igilima

Member
  • Content Count

    262
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Igilima

  • Rank
    Member
  1. Igilima

    Synchronization Issues

    If I understand your explanation correctly... 1. Your client tells the server that the avatar is moving left. 2. Then the client just moves the avatar left in its copy of the world. 3. The server then uses the "moving left" message to move the client to a new position in its copy of the same world. Is your game client/server so that you can have multiple clients? If you answer yes then that just makes the following recommendation even stronger because you don't want your clients getting out of sync with each other and because you are going to have to send out position updates to 1 or more other clients anyway. 1. Have your client send a request to the server to move the avatar to a new position (using either absolute coordinates or move direction) and then go ahead and start moving that direction (this is prediction on the client's part because the server is the ultimate authority on where the avatar can move). 2. Have the server evaluate the move and send out an update that says where the client is each "tick" until the avatar has arrived at its destination based on the movement request (either the avatar is in the same position because there is no alternate pathing, it is going around because you allow it to calculate an alternate path when it is blocked, or it is in the predicted position along the initial path). 3. If the client receives an update with a position that indicates anything different from where the client's avatar is currently then the client's avatar must be moved to that new position because the server is the ultimate authority, not the client. Obeying the server may cause "jumps" once in a while if your server calculates a different path from the client's prediction. "Jumps" aren't good and you want to fix them but at least they keep your game synchronized. 4. If you get "jumps" then figure out why and either fix them or smooth them out. Perhaps "jumps" are caused because the pathing algorithm on the server is different from the one on the client. Hopefully it is the same code. Perhaps, even if it is the same code, the server and client are getting different numbers because of floating point math? Maybe the server has more or different information about the path (NPC or another player wandered into it?) that the client did not have when it first calculated the new position(s). If so then the server has to send out an update as soon as the path changes and the client has to obey the update.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!