How to optimise hundreds of humanoids

image

Each cube has a humanoid in it, which moves through a series of waypoints then gets destroyed, and I was wondering If I should even use Humanoids at all for this, since there are too many, I already disabled every state except “None”, and don’t knwo what else to do.
The game runs but with a noticeable lag spike.

1 Like

If the cubes aren’t being animated, you should tween the movement of the blocks without Humanoids. Unless you’re doing something entirely different (in which case, what are you doing?)

2 Likes

if you dont need physics then dont use humanoids

if you need animation then
https://developer.roblox.com/en-us/api-reference/class/AnimationController
is faster then humanoids

tweening is not the fastest method

its better to position them in
https://developer.roblox.com/en-us/api-reference/event/RunService/Heartbeat

here is a demo i made

500_enemys_running_at_60_fps.rbxl (36.2 KB)

16 Likes

I see, gonna check that out, should proably be a bit easier for me since I don’t have animations, heh.

How would you do turning with this? (I think i’ve got it, I will edit with code in a bit)

I started doing this on the server, and was very laggy, then tried doing the same on the client and It was jsut as laggy, maybe I should use body movers?

Body movers seem to lag the game the least

I ended up using BulkMoveTo() and iterating through some very large tables, which seems to be the msot efficient solution so far, pretty similar to what you did here.

You should anchor the parts then it will have better performance as anchored parts don’t have any phisics calculations

Body movers are deprecated they should not be faster then anchored parts

Here are the new body movers

But the new body movers will not be as fast as setting cframes for anchored parts because they use phisics

Having the parts on server side will use a lot of network bandwidth

While having them on client side will have no network usage

This video might give you a idea on how to control npcs that are on the client side

3 Likes

here are some demo projects that might help you
SpawnEnemys.rbxl (36.7 KB)
Server_keeping_track_of_enemy_positions.rbxl (33.9 KB)
spawn_enemys_without_a_loop.rbxl (35.0 KB)
500_enemys_running_at_60_fps.rbxl (36.2 KB)
FollowPath.rbxl (42.9 KB)

11 Likes

I just realised I hadnt marked solution :sweat_smile:

Hey, just wanna say thanks for the example places. I’ve enjoyed playing around with these for an idea for a new game we have. It will also help on another game where mobile players started to lag when I placed too many NPC visitors in to a zoo. Much appreciated.

Have you done a Community Tutorial on this as I think a lot more people would be able to use it.

1 Like

I hope to do YouTube tutorials of this topic

3 Likes

How would you make a system like this but on the server? Like how would you replicate this to every player without a big drop in performance like 300 of them at most? It is easy to do it all on the client but what about the server.