how to have hundreds of moving actors at the same time without lag

so as the title says im trying to have a lot of actors move to the player at the same time (like a 3d vampire survivors) and i have a lot of lag when i get to 500+. ive already turned down the lighting and every thing ii can graphics wise so i was wondering i someone knows a solution? (all of the actor have a basic ai move to player location with a 0.2 delay before reactivating) thanks in advanced

Well there is multiple things to consider in an opeeration in large scales

Here is a list to do

  • Use Object Pooling patterrn https://www.youtube.com/watch?v=f797l7YTcgc In anything you do.
  • Make sure you are using LOD for your characters and nanite can be helpfull in these kind of super crowded scenes
  • Make sure that you have a culling distance in your scene if you have thousands of actors spawning to horizon, maybe you don’t need to seee them at all
  • If you have heavy animations or calculations in your actors make sure to make their functions running when they are being rendered. Look for IsRecentlyRendered. If something is not being rendered on your scene maybe you don’t have to calculate all of their functions.
  • If there is sounds, decals etc make sure they are also pooled and optimised. For sound you can check concurency settings.
  • If you have same type of actors, vampirees lets say, you can share their animations also rather then each of them having same animation bp ticking, you can have a master and variations in between to give the imitation that they are doing different things.
  • This is also same if you are using animation motion matching if you are using. It means all actors will be having trajectory instancee, pose search instance etc so make sure they are optimised also, like maybe some actors don’t search if not rendered yet.
  • Your AI Move To. Maybe you don’t have to run pathfinding for each 500+ actors. You can run it once and others can only follow. Since they are all will try to reach player location without hitting the other agents, which is super costly.
  • Check your draw calls in unreal engine optimisation stat scenerendering, if you have large amount of draw calls you should be lowering those aswell, and it lies on good character optimisation.
  • When they are dead or even not dead try to avoid any physics. Physics is something you should be very carefull about what you arre doing. Unreal has nice physics engine and it can be improved in anything however by default would create problems if you have phsyics in your scene, be mindfull about those too.

Start with object pooling you will be fine.

1 Like

Hey cool_mA_n!
Hope you’re doing well.

In a game where there are lots of actors that want to chase the player you actually do not need ai. What you can do instead is to create a simple vector movement. Where all actors get the location of the player and each one uses a move to vector with the target as the player location.
And if it’s still not enough you can reduce the calculations from every frame to something like once per 10 frame. This means that each actor will get player location and moves towards it for the next 10 frames even if the player changes its location. This works because there are lots of actors and the player won’t pay close attention to each one and can’t notice because the time is too short. But it significantly reduces the calculations(10x).

That was the first thing that stroke my mind. So let us know how it goes.

ill try this first thanks

ill also try these thanks