Hi. i’ve been recently having some server lag issues with AI and i’ve been thinking of this solution I haven’t actually tried myself. I wouldn’t really call it a solution yet though lol.
Would the game have a drastic decrease in lag if I handled AI like this?:
I could have it when AI spawns in, it calls for a module that creates a path through the client (also updates the path via the client), But has the attacking and moving part run on the server. Could this possibly work?
(also; what i’m working on is heavily reliant on npc and player combat; so there is usually around 25+ AI in workspace at a time.)
If the pathfinding is a significant source of your lag, doing what you said could work, you just need to ensure to verify path validity on the server. You’d also have to keep in mind that there will be increased delay in routing.
I don’t necessarily think pathfinding should cause much server lag though unless you are trying to update it more than a few times a second. You should in most cases be able to handle the amount of characters you said. Is there something else that could be causing this lag?
Yes. I forgot to mention that every AI’s / NPC’s model’s torsos NetworkOwnership is set to nil; Which i’ve heard can contribute to lag when in large numbers.
Oh another thing; Every NPC has their own AI script (which handles pathfinding and attacking) Currently all AI does not run on one script in ServerScriptService or anything. But the module path creator I feel like could basically make AI run on one script pretty much if i were to add this (correct me if i’m wrong though.)