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.
- 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.
- 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.
- 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.