Client PCs helping with calculations

I think it’d be helpful if there were some way to let client PCs help out with resource-heavy stuff like pathfinding, which can only be done on server scripts right now. Or if not help, then be able to do it on their own.
My game Retail Tycoon I’ve been working on involves numerous customer NPCs pathfinding around. This can get to be pretty strenuous on the server when a lot of players have large stores with many customers. But I can easily double the amount of customers in those laggy servers on my laptop in studio and still get a buttery smooth simulation. I’m not saying all computers can do that, but 5-6 of them could probably help the server out quite a bit.
Would that be plausible?

1 Like

I used to do this with my A* path finding until I made it efficient enough that the server could run it.

It’s certainly possible. Use RemoteFunctions.

How would I do that with remote functions? You can’t use the pathfinding API from a LocalScript and if you have the LocalScript tell the server to do it that doesn’t change anything.

Edit: Oh wait I tried it and it does work in a local script heh. I assumed it didn’t because the pathfinding wiki page had a remote event telling the server to do it.

What would be a use case?

Like the scenario in my first post, with a ton of NPCs needing to pathfind. Now I see I can make something on my own to make local scripts help out, but it’d still be neat to have something like that built into roblox.

This is what I would do. I would run the NPCs on the client locally, and then every second give the server the location of the NPC and the movement vector of that NPC (AKA moving left,forward,right,etc) via a remote event and then tell the other clients from the server that the NPC is in this position and then moving in that direction via another remote event. If the NPC stops somewhere inbetween that one second the client is updating, then on the other clients computers the next update would kinda teleport the NPC into the correct position on the other clients computers. Im guessing that most of the time each player is in their respective shop so I dont think it would be a huge issue but yeah :stuck_out_tongue:

1 Like

That’s a really bad idea considering 16 players can approach 250 ping (especially if OP isn’t optimizing).

That means up to half a second between what should be there and what is there.

1 Like

How about if the NPC models and all that are on the server, and they just invoke the client to calculate paths? The pathfinding is what’s slowing everything down from my experimenting. Also, the servers are 6 players max (5 preferred).

Depending on how pathfinding outputs the results that could work as long as you designate that NPC on the server only to that client. And yeah spamming remote events isnt the BEST solution but with 6 players I think its doable if you experiment with it.

My mini golf game used to be horribly optimized where each client sends the position of the ball and the balls velocity to the server every 0.1 seconds lmao, the only reason for that is so each ball can slide through eachother. And then I realized I can make the ball on the server and then locally change everyone elses ball to can collide false with FE, and then im not having to spam any remote events.

1 Like

Not really helping with the code perse, but someone mentioned only putting the Torso parts in the Server, and simulate the limbs and head to the client only. This way the time it takes is lowered since the server is only moving a Torso around.

1 Like

That was me. I don’t think that’s what he’s doing.

He’s not asking about reducing latency, he’s asking about giving the server less stress when doing more intensive things like roblox’s slow Pathfinding.