Jump to content
  • Advertisement
Sign in to follow this  
Triad_prague

Where do I do pathfinding?

This topic is 2494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to build a simple test program that is basically a online games where players could walk and chat. the chatting part is not that hard, but the movement is quite stressing. basically, I'm confused at:
-where do I calculate/do the pathfinding? should the server do it and send the calculated waypoint to the client? or should the server only "validates" the path and let the client do the pathfinding?
-a follow up question from question #1:
a. assume I chose the server to do it, wouldn't it be bandwidth intensive to send the calculated path to the client and other players nearby?
b. assume I chose the server to only "validates", will there be a "difference" between the calculated path on the server and the client?

Share this post


Link to post
Share on other sites
Advertisement

Send the start and end, have the clients compute it.


so the client sends the start and end point, server validates and simulate it on the server, then tell the client to calculate it?

Share this post


Link to post
Share on other sites
What are you making? Why does the server need to do anything related to paths?
Isn’t it the client who decides the start and end points of a path? Why do you want the server to tell the clients what the start and end points are?

Client decides start and end points.
Client makes path.
Client walks along path.

That is all.
The server keeps the client out of walls, but that has nothing to do with paths. Keeping the client out of walls is something that is done all the time regardless of the client’s “following path” status.


L. Spiro

Share this post


Link to post
Share on other sites

What are you making? Why does the server need to do anything related to paths?
Isn’t it the client who decides the start and end points of a path? Why do you want the server to tell the clients what the start and end points are?

Client decides start and end points.
Client makes path.
Client walks along path.

That is all.
The server keeps the client out of walls, but that has nothing to do with paths. Keeping the client out of walls is something that is done all the time regardless of the client’s “following path” status.


L. Spiro


well I said the client decides the start and end path, the server only "validates" (check if it's a valid movement) and the client simulate it. what worried me is how would I synchronize the position in the server. so I thought the server needs to simulate the movement too. that would be client and server simulate movement each in their own, but I'm not too sure if that's how it works in most online games :huh:

Share this post


Link to post
Share on other sites
This would depend on your game. If it's a board game like chess you want the server validate or else the client could hack it to bypass the client side rule checks. Let's say they make their king move 6 spaces in a zigzag pattern because they were able to bypass the client side rules check. Locally they can do that all they want, but the server would validate that move and realize it's not valid and not update the server board or the opponents client board. So that cheating client is only cheating themselves because now they are out of sync with the server and other client.

Ideally the server would send back to the cheating client a 'no no' msg and move the piece back but chances are if they hacked their client they'll intercept that 'no no' msg and not let it get to the application.

You will want the server to do some kind of validation. It could just be sanity checks like making sure the King in chess only moves 1 tile.

Share this post


Link to post
Share on other sites

This would depend on your game. If it's a board game like chess you want the server validate or else the client could hack it to bypass the client side rule checks. Let's say they make their king move 6 spaces in a zigzag pattern because they were able to bypass the client side rules check. Locally they can do that all they want, but the server would validate that move and realize it's not valid and not update the server board or the opponents client board. So that cheating client is only cheating themselves because now they are out of sync with the server and other client.

Ideally the server would send back to the cheating client a 'no no' msg and move the piece back but chances are if they hacked their client they'll intercept that 'no no' msg and not let it get to the application.

You will want the server to do some kind of validation. It could just be sanity checks like making sure the King in chess only moves 1 tile.


Do you have to worry about cheating in your chat application? If not, then I wouldn't fret about it too much. Have the pathing be done on the client side. When the client updates the server, the server will check to see if the client is in a valid location. If he is not in a valid location, send back a response that tells them where they should be. The simplest way for the server to do this would be to just send back the player's last known valid position. When the client receives this information it should either: Calculate a new path from the position the server responded with, or simply stop moving altogether. This will get the job done.

It could allow the player to cheat, though. Consider a situation like this:


W: Wall
".": Valid position
@: Player
X: Destination

WWWWWWWWWWW
W....W.....W
W....W.....W
W..@.W..X..W
W....W.....W
W....W.....W
WWWWWWWWWWWW


There is no valid path for the player to the destination X. They're each blocked by walls on both sides. With only validating positions and not paths, the player could send the server a packet with its position inside that unreachable room, and the server would allow it. You can somewhat mitigate this by setting a maximum distance the player can travel between server updates, but that won't work all the time and can cause the client to seem laggy if it can't get updates to the server that often. Another potential solution is to, on the server, draw a line from the player's last known position and the new position and ensure that all positions along the line are valid positions. You could also prevent another kind of cheating using this method by making sure that this line is no longer than the distance the player could actually move in the time between now and when the player was at the last known position.

Share this post


Link to post
Share on other sites
I'm confused because it sounds like we are saying the same thing. Have the server do validations/sanity checks.

Share this post


Link to post
Share on other sites

I'm confused because it sounds like we are saying the same thing. Have the server do validations/sanity checks.


We are. That's the only sane way to do it. I guess we're all just giving ways he could do it on the server

Share this post


Link to post
Share on other sites
What are you making? Why does the server need to do anything related to paths?[/quote]
Uh well the server needs to tell the other people where this player wants to walk. Send the start and end points to all the players. You could still have some lag though that someone doesnt get the walk command right away and then you will still have some lag issues.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!