-
What do you want to achieve? Keep it simple and clear!
Fix the very slow walking and keeping it performance-friendly. -
What is the issue? Include screenshots / videos if possible!
Very slow walking and would like to have ideas how to achieve more than 1500 NPCs, After I reach 1500 NPCs I get over 400-500 ping. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Still finding more solutions to have more NPCs and performance-friendly. Would like some ideas to achieve more than 1500+ NPCs without lag.
well, obviously there would be lag with 1500 NPCs
you can’t really do much when it comes to optimising npcs
I can’t really say much since I don’t know exactly what optimizations you’re preforming so I’ll just give a general consensus on what I remember:
Basic animation optimization
Culling on the animation/characters (if not in view, stop focusing energy/performance on them)
Optimizing mesh/parts of the character, make further npcs less detailed/use less performance heavy meshes
Basic collision optimizations, with enough parts, even the most basic of parts can become laggy when multiple collisions occur.
Shadow performance, often overlooked but if the characters are far enough, disable shadows on them
Don’t know how you handle movement but try to make the movement part “client” based with the server handling verification checks (checking where the npc should be).
Client = effects, server = verification
https://gyazo.com/1eeac2045bb1a3af9d535dc9bc1dfdb5
I think it is possible. I’ve seen it like this the NPCs are basically meshes but their appearance maybe client-sided. They managed to get 3k NPCs.
I’ve been interested on this idea for a while when I played Zombie Survivors - Roblox and planning to make one. Here’s some handful resource that I got upon researching.
Nothing you can do except: Making one script to control each one of the npcs. Don’t put individual scripts in each of the npcs. Make it one giant long script that controls every such npc.
I’m actually working on a game with my friend
we have an automated citizen script spawning and deleting npcs
all it does is clone a disabled script, clone a citizen and put the script in the citizen
though, this may not help but I have tested it with 100 npcs once and performance wise, not much of a difference when comparing with performance
That is what I did, One script to control them all.
So did it solve it or not?
can I see the script?
(remove30characterrule)
Right now, It can only take 1500 NPCs but at the cost of ping having 400+. So maybe it’s solved?
I used CollectionService for it, I used this video but made my own similar to it. Something like that.
you can probably use streaming enabled
I cant give a direct link but suphi kaner has a great tutorial for it
I’ll look into it. Thanks for answering
Thank you for this, this made it much more better. StreamingEnabled really helped the performance. I get 100-200 ping from 700-900 NPCs and 200-300 from 1000 NPCs. Although the NPCs are very slow.
How’d you get 1500 NPCs that’s amazing. I can only manage 200-400 NPCs
So, you have to give up on direct position syncing and instead use direction and mag vectors only. And only change or update them if they are changed in some way.
The idea is you can simulate more and have to send less data per frame because the only timw the client will be informes is when the vector has changed.
Otherwise the client can simulate the position of the character and since the server is emulating this tye clients simulation will be very close.
Again this is an over simplification, update rate limiting by distance, culling by whats in view plays a large roll ontop of ensuring your update data is as small and clean as possible.
Also, if these npcs dont need to ve synced and are all managed client side, hutting that number is not unfathomable.
You could also make a CollissionGroup for all NPCs and set their own CollissionGroup to CanCollide false. This prevents the collissions between NPCs which should reduce lag aswell. Except you want that NPCs can collide each other.
I’ve never made this many at once. If I tried that I think I would make a script that controlled all of them at the same time. Be no need for each to locate a target like that. If you wish you could even give a few one target and a few a different target. The NPCs would just move along the path. Would have to play around with it a bit to see how much you can take away from the NPCs script and do in the master script.
The server handles the npc information such as position in a table, use that position to pathfind and u will get array of pathfinding points, use those points in order by putting task.wait(amount of time it will take before the npc reach next point by calculating the magnitude between 2 points divided by the npc walkspeed) then update the npc position in table into the next point, and the client have local script that creates npc and position them with the position the server is telling u for each npc, By doing this, u save the server from having to calculate the physics of each npc, so it gets way faster, also u can put the npc character into replicated storage if they are too far from ur player, so ur device wont need to render that, but the position still gets updated whenever u receive new data from the server