NPCs Causing Lag - Feedback on Memory Usage

So I had about 30 NPCs in my game that ran around and moved with animations, however, this caused a plethora of lag, client side and server side. So to combat this I created a client side script basically setting a max render distance, if an NPC wasn’t within a 25 stud distance of the player, all of their parts would change to CanCollide = false. This however, didn’t solve the lag problem, so now I shrunk the amount of NPC characters to roughly 20 and only a select few of them can walk, the rest just stand there idly, while also keeping my can collide render script. This seems to have fixed the lag, however I am unsure. I was wondering if you can take a look at this screenshot and let me know if that’s a good Memory usage number to have in the developer console while in-game.

If you have had any similar problems, please let me know how you solved them as well, through code, or game-settings.

Well from my experience with working with AI in the past and currently, I have a question, Are you using the default Animate script? If so is it a local script or a normal script?

I am using the default Animate script and it’s a script, not a local script.

Hmm. I have found that the default animation script can be quite compute intensive and often times Ive had to write my own. This is why in Restaurant Tycoon and Retail Tycoon you see the AI have lower FPS animations the farther away they are. The animation script has a lot of overhead.

1 Like

That might be the best way for me to go then, I’ll have to create my own animation script and see if that helps out at all.