Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to design an MMO where players click the destination they want to walk to with their mouse and the character moves there, similar to Runescape in this manner.

I think it should be easier than keyboard movement since the client can simply send the server the destination each time the player clicks on a destination.

The main thing I'm trying to decide is what to do when there are obstacles in the way. It's no problem to implement a simple path-finding solution on the client, the question is if the server will do path-finding as well, since it'll probably take too much Computation power from the server.

What I though is that when there is an obstacle the client will send only the first coordinate it plans to go to and then when he gets there he'll send the next coordinate automatically.

For example if there is a rock in the way the character will decide on a route that is made of two destinations so it goes around the rock and when it arrives at the first destination it sends the next coordinate.

That way if the player changes destination is the middle he won't send unnecessary information.

Is this a good way to implement it and is there a standard way MMOGs usually do it?

EDIT: I should also mention that the server will make sure all movements are legal and there aren't any walls in the way etc. In the way I wrote it should be quite easy since all movements will be sent in straight lines so the server will just check there aren't any obstacles along that line.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

If you don't want to do full path finding on the server, I'd do something like this...

  1. Receive click from user
  2. Client sends click location to server to see if it is legitimate
  3. Client calculates path to click location (if legitimate)
  4. Client begins walking along path
  5. Server is checking for collisions on each movement
  6. In the event of a server-detected collision with an item, the server sends a "cancel path follow" message back to client, and resets the player position back to the last known legal position

You can certainly skip step 2 as theoretically the client will also recognize the click location as not legitimate, assuming it has all the obstacle data to calculate paths.

share|improve this answer
    
Point 5 isn't very clear to me: when you say "Server is checking for collisions on each movement", what is "each movement"? what is a movement in this sentence? –  fiftyeight Nov 21 '11 at 21:47
    
Each step the player takes, the server checks to see if the player can actually walk in that area. If they can't walk in that area, then a collision occurs because they have stepped into an unwalkable area. It might be that they tried to step into/through a wall, an object on the ground, or even another character. –  Tim Holt Nov 21 '11 at 21:49
add comment

It's a good idea to make pathfinding an async service that you can offload. Done this way you can have a dedicated server for nothing but pathfinding. Of note is that you will only be pathfinding across small areas with this click idea and therefore the actual "computation power" required won't be as big as you think. Measure, measure, measure when performance is concerned =)

It's never a good idea to let the client decide anything about movement. What smooth feeling MMOs do is let the client create a path based on the click and immediately start moving, then the server will return with move updates based on the path it created (like usual) and the client will abandon its own path and simply work from the server's input.

At least that's the way that I've seen it done. I'm looking forwards to following this and seeing other solutions!

share|improve this answer
    
Hi, I'll edit my question to reflect this also: In the implementation I wrote, the server will make sure movements are legal, I didn't point that out on my question. It will probably be quite easy for the server since the movements will always be sent in straight lines since the client already did the path-finding. About the path-finding server idea: you mean there will be a path-finding server that all movements will be routed through? –  fiftyeight Nov 21 '11 at 21:25
1  
Yes, "a path-finding server that all movements will be routed" makes it easy to simply make it another process on a box or to move it to a dedicated box as needed. You can also spin up multiple path finding services and load balance them. Very easy to optimize and all it needs is a movement map and no other game data. OK, load balancing path finding is overboard =P But little, independent services like that make being flexible and optimizing really easy compared to a monolithic setup. Your other idea will work, I'd actually do that first and see how well it handles! –  Patrick Hughes Nov 21 '11 at 22:19
add comment

If your client has all the information it needs to be able to do the pathfinding correctly, it can do it, and then move the player just by steering it around (as you would for a 1st person game, or a vehicle-based game, etc). The server just needs to validate the position and ensure the player doesn't pass through obstacles as usual.

Otherwise, the server should calculate the path, and then you can choose: either you send that to the client to allow the client to steer, or keep it on the server and move the character directly.

I can see the attraction of wanting to save bandwidth by only sending the destination from the client to the server, but remember that in MMOs you usually use between 5x and 50x as much bandwidth broadcasting your changing position to observers anyway. (Just sending destinations is rarely sufficient there, though I'm sure you can hack it with a few edge cases.)

share|improve this answer
    
When you say just by steering it around you mean just constantly sending the server the player's coordinates? can you explain the advantage of this? –  fiftyeight Nov 22 '11 at 0:34
    
The advantage is that it's simple. The server doesn't have to perform any calculations apart from checking the location is not in an obstacle and is close enough to the previous one. –  Kylotan Nov 22 '11 at 13:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.