Managing many actors

Does UE4 have any built-in support for managing very large numbers of actors? I’ve found that I can get away with a thousand or two on a mid-range system with decent performance. But I’d like to go to millions of them.

I started working on a system for testing a bounding sphere for each actor against the camera frustum… Kind of a brute-force approach where I’d destroy any actor that moves out of the frustum and re-spawn any actor that moves in. Pretty messy and very difficult to do efficiently.

But then I thought maybe there’s already a similar system in the engine since large terrain is now supported. Anyone know?

You’ll need to come up with some sort of custom solution for this kind of simulation.

Something akin to this:https://youtube.com/watch?v=iNC2X9r0oGY
But on larger scale.

With few millions of properly simulated actors you’re bound to hit memory limit and general slowness.

You need to treat them as some sort of particle systems where each actor is internally represented as something like a dot or doesn’t even exist, but is spawned as AActor on demand.

That’s pretty much the way to go.

Thanks, NegInfinity. I had a feeling I’d have to do it with custom code, but I figured I’d take a shot in the forum first.

My actors are much more static than the ones in that video, so it won’t be quite as complicated.

Afaik, in hitman crowd scenes you have one actor which has complexity of a particle in particle system, pretty much. No ai or anything. That actor is then duplicated across the scene, sometimes with multiple meshes with slight variations. If you look at the crowd you may spot situations where several people perform exactly the same animation. Not exactly sure which game had this - contracts or blood money, though, I think both of them had crowd scenes except blood money was less obvious about techniques it used. If you attempt to interact with crowd actor, it is seamlessly swapped for full-fledged actor. The reason for that is that calculating animation properly for large number of people may quickly result in large computational overhead (it is less important now, because hardware is more powerful), so it is easier to duplicate it.

Also look up information on “instancing” and total war series on the web. There bound to be some siggraph/gdc papers floating around, plus gpu gems might have some info.

Keep in mind that there MIGHT be some mechanism in UE4 that is specifically aimed at that, but I am not familiar with it and I did not work with it. I did come across mentions of Crow Controller in the code, if you search engine source for “Crowd” you might come across something that will help you.

I was actually thinking more along the lines of trees, rocks, and so on. There was a lot of talk about the new huge landscape support. The core of that is just the ability to have really giant heightmaps, as far as I can see, but the “kite” demo also shows lots of trees, foliage, and even some animals. So I’m wondering if they have some magic for managing huge numbers of actors that aren’t the heightmap. Thanks again for the advice.

The trees and rocks in the Kite demo are using the built-in foliage system. You can read more about that here: Open World Tools in Unreal Engine | Unreal Engine 5.3 Documentation

Other than that, there is the InstancedStaticMesh component, but there’s currently no nice editor features to support it so it’s a bit of a hassle to use.