Optimizing hundreds of Moving NPCs Rendering

I am trying to get ~300 NPCs to be actively running. However it seems the characters are very expensive to render at this high quantity in such a small space.

Optimizations I have already done:

  • Client side rendering
  • Disabled EvaluateStateMachine on Humanoids
  • Making characters out of frame transparency’s 1

Looking for anything I can do to get down the CPU and up the FPS

use BulkMoveTo instead of making the character walk if they’re far away.

That won’t pivot the whole character though? Unless I’m misunderstanding

oh my bad, you’re right.

idea 1:
how about a system where you determine the quality of a characters movement?

  • if they’re close to the camera, use walkSpeed and whatnot + other animations.
  • if they’re medium-far from the camera, call PivotTo every 10 seconds or so, updating their position.
  • if they’re very far from the camera, don’t render their movement till they’re closer.

depending on how you store a characters walking path, you could do this nicely.

idea 2:
also there may be a perf difference between turning transparent and moving them to somewhere very far like 1000000 studs in the air. (partCache inspired idea)

idea 3:
if your characters look very similar, you could also get away with just using partCache in general. itd just need to be edited to work with models.

idea 4:
use humanoidControllers over humanoid. you can get serious optimizations because when using these controllers, you pick what features you want to have. it’s like disabling evaluateStateMachine but it’s probably way more optimized because it’s a newer feature and it’s actually recommended for stuff like this.

if you have any other features/ideas for your characters that don’t work with these ideas, let me know. i really like coming up with solutions for optimization. also i separated the ideas for neatness, but all of them can be used together.

1 Like

I have tried both idea 1, and 2. but the problem was is the CPU would spike because it would change position/transparency or whatever of a ton of objects at once and spike CPU, especially if I rotate my camera back and forth

Idea 4, I don’t even have humanoids so would cause more damage than good

could use a debounce here. this is what roblox does for streamingEnabled to prevent constant loading and unloading. make the character have to be on screen for more than a few frames.

also, you could create a priority system, choosing to only update 1/4th of the characters and some sort of algorithm to pick which ones that would be. (ones closet and in-frame)

how many times are you updating per frame? you could easily limit it to 20-30hz, nobody really pays attention to characters anyways. (im assuming theyre background noise and unrelated to gameplay)

Good idea. thanks. the other two ideas I am already doing.

I decided to switch to a tween, I found out that if you CFrame the HumanoidRootPart the rest follows. I was maybe considering BulkMoveTo.

Thanks

Hey, wanted to bump this again. While this all helped greatly, I welded 1-2 accessories to each characters and now getting big jumps. Any optimization ideas? I am already cloning them so it saves some memory from initializing