Been stress testing my NPCs in-game. Seeing how everything is handling. Each one has a humanoid inside it. All they do is walk from point to point, nothing else. These are the things I’ve done to increase performance:
1 Main NPC Handler
Safe guard to remove the NPCs after an X amount of seconds incase something fails (Like they never reach their destination)
Added them to collision groups
All BaseParts cancollides set to false
Disabled all States except Freefall (When they move down the steps)
local npcClone = npcTemplate:Clone()
-- Disable unnecessary humanoid states for optimization
local humanoid = npcClone:FindFirstChildOfClass("Humanoid")
if humanoid then
local statesToDisable = {
Enum.HumanoidStateType.FallingDown,
Enum.HumanoidStateType.Climbing,
Enum.HumanoidStateType.Ragdoll,
Enum.HumanoidStateType.GettingUp,
Enum.HumanoidStateType.Jumping,
--Enum.HumanoidStateType.Freefall,
Enum.HumanoidStateType.Seated,
Enum.HumanoidStateType.Flying,
Enum.HumanoidStateType.Physics,
Enum.HumanoidStateType.PlatformStanding,
Enum.HumanoidStateType.Swimming,
}
for _, state in ipairs(statesToDisable) do
humanoid:SetStateEnabled(state, false)
end
end
npcClone.Parent = game.Workspace.Noobs
Right now I have about 100 NPCs in-game the entire time. It will not be this many in the final product, maybe around 60 at most.
I’ve been averaging around 1000-1100 MB for my memory over time too.
Remove Humanoid’s altogether, they’re laggy, even if you’ve disable majority of the Humanoid features.
Well what do you replace them with? Attachments. (I’d also lerp the attachment and not tween)
Don’t feel like explaining all the nitty gritty details right now so I’ll just toss you a video.
It’s not the best but the dude does point out how he did it and such.
Just wanna say, using his method allowed me to get up to 500 Units. Could’ve also made it better by having a Main Unit Handler but got bored with my TDS project :P
Yeah that is something I might consider doing, maybe. Thanks for the feedback though! Also 500 units is crazy large lol. I’m not planning on ever exceeding 70 really…
1000 megabytes is a good amount to run at, if you check, I lot of games tend to at 1200-1600.
The biggest thing you can do to save resources, is recycle NPCs. When an NPC dies, instead of destroying it, reset its stats and set it aside. These “stored” NPCs can be brought back when needed instead of creating new NPCs.
Creating or cloning instances is by far the most memory heavy thing you can do.
Interesting ideas here. My first ever Roblox game was ‘If you’re happy and you know it shoot a Zombie’ and back at that time 2015, I could only get about 50 npc zombies before it was too laggy.