Download

Get All actors in a UE5 level?

I want to get all actors in UE5 single level with code below, but some staticmesh actor was unloaded cause of UE5’s world partition( cell based streaming). Is there any other way to get all staticmehs actors in the level?
for(TActorIterator It(World, ActorClass); It; ++It)

If you want to iterate through the actors, do it this way:

for (TActorIterator<AStaticMeshActor> ActorItr(GetWorld()); ActorItr; ++ActorItr) {
                // "*ActorItr" is now a pointer to each Actor
}

Otherwise, you could use GetAllActorsOfClass to get them in an array.

I am using GetAllActorsOfClass for all staticmesh actor, it works in UE4‘s level, but in UE5, some staticmesh actor was unloaded(they are far from our view) cause cell based streaming. I want to get all staticmesh actors in the level.

Oh, sorry… I haven’t used level streaming. I can’t help then.