Limit "Get all Actors of Class" by sub-level?

Hi,

Is there a way to limit the search for actors by sub level? Example: Get all Actors of Class → ForEachLoop → DestroyActor destroys all actors, in every level. I just want to limit that to one sub level. Is this possible in blueprints?

Thank you

No, this isn’t possible. The “GetAllActorsofClass” node will pull all actors within the game world, which includes all sub levels.

The best work around would be to store a list of specific actors within an array and then delete all objects in that array when you no longer need them.

Thank you, thought as much.

Hoped I could take a shortcut but I guess I’ll have to spend a bit more time :slight_smile:

Solved. Isn’t possible but you can either put them in an array or just tag them and compare the results of the search to that tag.

I know this is an old thread but wanted to add an answer for future people since I ran into the same problem. You can do it in C++ (using StaticMeshActor as an example):

for (TActorIterator<AStaticMeshActor> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
     ULevel *LevObj = ActorItr->GetLevel();
    if(LevObj->GetOuter()->GetName().Equals(DesiredSublevelName))
    {
    ...
1 Like

You can get all actors of class and then loop through the array and check the outer object. You might have to do multiple outer object checks until it returns object of class World.

1 Like