0
\$\begingroup\$

I'm trying to build a little MOBA game (max 10 players) in Unity and i'm really stuck with the pathfinding / local avoidance.

Here is what i'm doing when user click to move on the map:

  • Client send a MovementPacket containing the target position to the server
  • The server will calculate a path using a pathfinding library
  • The server will send back this packet with a list of points to all the clients
  • Clients will use the same library to follow the points

This is basic and working pretty well.

But problems appears if I want obstacle avoidance between the players (like in League of Legends for example, you can't walk on other players).

Let's say the pathfinding library i'm using (Aron Granberg lib) handle local avoidance, the only "easy" solution I see is to use it on both the server and client side.

But I'm afraid it won't be in sync (for example the RVOSimulator of this library is running at a specific tick in the Update function of unity, but what happens if I have FPS drop on client side?).

Do you know a better way to handle it? It seems to be pretty complex, how do they handle it so well in other mobas ?

Thanks.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Unfortunately syncing between games is an extremely complicated problem. There is no simple solution. There are literally entire books on this subject.

The usual solution is to have the server sync the positions of every single unit on the map to all clients multiple times a second. When the client is out-of-sync with the server, you'll need to do clientside interpolation to get things in-sync without looking jarring to the user. This might mean lying to the user about the actual position of things sometimes. This can be reduced with techniques like input prediction, lag compensation, and various other techniques depending on the game.

I believe the above option is what LoL and Dota 2 do. However for games with a lot of units, syncing every unit multiple times a second is not realistic. RTS games like Starcraft (where MOBAs originally come from) use deterministic lockstep (more info), where every client computes the path independently then executes the pathfind simultaneously. This means the game must be completely deterministic, which is non-trivial. It also means that, when one person's computer slows down, the entire game must slow down for everyone. If you've ever seen the message "XYZ is slowing down the game" in Starcraft, that's why.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .