Optimizing 50+ Humanoids

How can I optimize 50+ humanoid entities?

I’m currently creating a basic PvE game, whereas there will be enemies that spawns and chases you in an attempt to kill you; It’s all doing great so far, but unfortunately the game’s server quality starts to fall apart after 50 or more enemies are in the battlefield. The system I’m currently using is really old and messy, although it works.

I have tried all of the optimization methods for said humanoids (Disabling unneeded humanoid states, like 90% of them, optimizing scripts especially connections, and optimized pathfinding)

After a few debugging, I’ve came to the conclusion that having a lot of Humanoids with each trying to move to the player is mostly the issue.

What is the server handling?

  • Basic damage system with defense and resistances and whatnot
  • Animations, and Animations cues for the entity (Required since attacks are tied to animation)
  • Entity pathfinding, and entity attack-registry

I’ve been going on at this reading a lot of articles and resources and I can not seem to advance further in my humanoid optimizations, what should I do? Do I just stop since it’s not possible?

Any help appreciated!!

3 Likes

You might be able to use the camera to find entities that are not currently in view, and unload/delete them until they come into view. (Something using camera:GetPartsObscuringTarget() and camera:WorldToScreenPoint())

1 Like

afaik, the client is not experiencing any issues regarding entity rendering, it’s just the server that suffers a huge lag:

https://gyazo.com/6fb39b9daf649082eb3fd8afbb9f1462

I cant really think of much, then. It’s still worth a shot unless you come up with something else. Who knows? It might fix it.

Though, yeah, it looks like a server thing. I’ll think about it for a little while and I’ll come back if I think of anything.

EDIT: If you haven’t already, try using multithreading or whatever it’s called. It’s supposed to help, but I wouldn’t know. Also, use RunService sparingly, and break up tasks between frames with task.wait() (I’m guessing you’ve done that already though.)

EDIT 2: Also an idea, use something like tick() to find where the delays are happening, and go from there.

render humanoids on the client, the server WILL store positions, all only required stuff and calculate paths and send that data to client, and in serverside damage script check if position of server enemy data is close to players position

On this matter I found a good videos you can use
– First Video

– Second Video

1 Like