[Kryonet] Runescape style movement

I’ve been wondering how to implement a movement system similar to that in Runescape. Basically the world is a grid, a player can click on a grid tile to find a path towards it. Up, down, left, right and diagonal movement would be allowed.

I’ve thought of a few options.

  1. Player client clicks on tile > sends move request to server > server does checks (can walk on tile, distance to tile is short enough, etc) > send move player packet to clients (packet contains destination tile and player id for example) > client receives packet > client finds path towards tile and moves towards it.
  2. Player client clicks on tile > sends move request to server > server finds path to destination > sends list of points that make up the path to clients > clients use path data to move player.
  3. Player client clicks on tile > sends move request to server > server finds path to destination > player moves on server > server sends packet to client every time the player changes tile (or every x times a second) > client receives packet and moves player by 1 tile.

Number 1 seems like a bad idea, letting the clients find the path towards a location. Number 2 seems better but sending path data to clients seems a bit expensive. Number 3 seems good but might be tricky to implement and might not feel that stable.

As far as I remember, the runescape client had the pathfinding code in the client but the “collision” was handled on the server side. So #1 is actually the most true to the original game.

So the client would find the path, ask the server can I walk this path, the server checks if the path collides and tells the client yes or no.

Would that involve the server also finding the path to check if its valid, or would the client send the path to the server to check, so the server never does any pathfinding.

Why would the server need the path? The client is just asking whether it can go from square A to square B. It doesn’t need to care about square C or D or E…

If you’re really worried about users hacking the client to make arbitrary moves, then neither option 1 or 2 will prevent that. But 99% of the time, these kinds of concerns are premature.

Yeah good point, I was thinking a better method might be to let clients do the pathfinding and have the server validate each move to a new tile before sending the move order to other clients.