Find all actors in the world within a given bounds

I am looking for a way to find all actors within our world partition, included nested level instances, that fall within a given bounding box. I can do this already IF all the actors I am interested in have their collision turned on. This is done using:

unreal.SystemLibrary.component_overlap_actors(volume, volume.get_world_transform(), object_types, unreal.Actor, [])

The hitch here, obviously, is the requirement that all of the actors have collision turned on. A second approach is to traverse the full list of actor descriptions like:

actor_descs = unreal.WorldPartitionBlueprintLibrary.get_actor_descs()
for actor_desc in actor_descs:
    mesh_min_bounds = actor_desc.bounds.min
    mesh_max_bounds = actor_desc.bounds.max
    # check overlap with the volume bounds
    if check_overlap(volume, mesh_min_bounds, mesh_max_bounds):
        overlapped_actors.append(actor_desc)

But there is a downside here as well. I can find no way to get from an FActorDesc to an AActor.

I should mention I have gone a full 12 rounds with the Epic dev AI and have gotten no where. It will talk you in a circle and eventually come to the conclusion “Now that we have a list of FActorDesc you just need to convert those to AActor and you are done” which, funnily enough, is exactly what I was asking it to do!

I have also tried

    UWorldPartitionEditorHash::FForEachIntersectingActorParams ForEachIntersectingActorParams = UWorldPartitionEditorHash::FForEachIntersectingActorParams();
    
    WorldPartition->EditorHash->ForEachIntersectingActor(QueryBox, 
       [&OverlappingActors, &QueryBox](const FWorldPartitionActorDescInstance* ActorDescInstance)
       {
          FBox ActorBounds = ActorDescInstance->GetEditorBounds();
          if (ActorBounds.Intersect(QueryBox))
          {
             OverlappingActors.Add(ActorDescInstance->GetActor());
          }
          return true; // continue iteration
       }, ForEachIntersectingActorParams);

But this only iterates over the loaded actors. It seems like the default values in FForEachIntersectingActorParams should ignore whether something is spatially loaded or not, but it only traverses the loaded actors.

In conclusion, it seems that component_overlap_actors() is able to traverse everything in the world, loaded or not, just fine. If I can be pointed at how to do this I am happy to do all the bounds checking myself. Or, since get_actor_descs() will give me every actor in the world as an FActor I’d accept a way to get from that to an AActor as well. Maybe there is an iterator in the code somewhere that will iterate all actors, loaded or not, in all next level instances, and is in a form I can get an AActor from it?

I am happy to have a python or c++ answer. I can wrap whatever you provide to give my pipeline code access via python anyway.

[Attachment Removed]

Hi there,

Through your GetActorDescs method you could use the Guid property from FActorDesc. It maps to an AActor’s ActorGuid property. So you could then check this against the actors in your world for a match.

- Louis

[Attachment Removed]

But that brings me back to the same question. How do I get all the actors in the world? If I have the full list I could use them directly or use the FActorDesc and jump across using the guid. Either way, I need the full list.

[Attachment Removed]

HI again,

In this case I would recommend using GameplayStatics::GetAllActorsOfClass or implementing your own version using a TActorIterator<>.

However you will not get any unloaded actors this way. You can temporarily load the data layers for actors relevant to your search. Depending on your context you will want to use either the Data Layer Manager for in editor runtime or the Data Layer Editor Subsystem. FActorDesc has an array of FSoftObjectPath to Data Layer Assets that actor belongs to. Using that you should be able to load/unload the relevant actors.

I hope that helps, If there is anything I have missed please let me know.

- Louis

[Attachment Removed]