Bad idea to trust client pathfinding?

So I am currently working on this large scale rts, which requires using a lot of pathfinding. The problem is, I obviously cant pathfind on the server, since it takes long to compute paths, and the server would extremely lag. So I came up with an idea, anytime the server would like to pathfind, I would invoke it on client and just send the results back. I know its really bad idea in terms of safety, mainly because of hackers and stuff, but I cant think of any better idea. But I also think the risks could be minimal if its done so only the player’s units use the player’s client for path computing. What are your thoughts about this?

1 Like

This sounds like a bad idea. Even without hackers etc, What if the client disconnects mid computation? Will the server be waiting for a return? You would also encounter lag to and from the client, and would need to have additional sanity checks, and a timeout handler to send the pathfind calculation to a different client.
It might be different if the pathfind was to be only used on the client though.
Do coroutines not help here?

I think that if the player disconnects, there wont be any need for his “units” to compute any path, because there wouldnt be anyone to issue them orders or something. And how would coroutines help in this situation? They wont change the performance impact the path computation does in any way.

I don’t know how many ‘units’ you are expecting to move at any one times, but Justice the Awesome NPC system can easily cope with 500 NPCs constantly pathfinding without lag.

Could you provide me with a link to this NPC system you speak of?

There is also buried in the depths of the forum an extremely good article about network optimisation for an RTS and how they achieved very low data transfer rates with variety of optimisation methods. They run through each step they used:

1 Like

I’ve actually read this post from Astrazine and even exchanged few messages with him, and the NPC system looks very promising. Thanks for your help!

1 Like

I’ve read through the whole source code for the “Justice”, and I must say that I am very dissapointed in it. It is nothing more that classic roblox pathfinding and looping through the waypoints with humanoid:MoveTo(). It isnt any better in terms of server performance

This is probably a late response but try setting the network ownership of the humanoidrootpart to “nil”. Therefore, it doesn’t sent signals to neither channels, hence less lag and non-jittering "walkto"s.

If you don’t understand what I mean, I’ll try to find a video on it to show you.

I totally know what you mean, but this “jittering” you are talking about isnt my problem. My problem is in the high time pathfinding takes to calculate a path, resulting in total lagging of the server.

Oh! Sorry. I’ll go look for a solution.