How to get subclass array reference from UGameplaystatistics::GetAllActorsOfClass?

I’m sorry if this is badly put. Here is my issue

I use GetAllActorsOfClass to get all actors in the scene of the ASomeActor class

It outputs to an array of AActor

I want it to output to an array of ASomeActor

How would i achieve that? any help is greatly appreciated :slight_smile:

could you provide a code sample of what you currently have please?

Yes, intuitively you’d think that when you specify a class, GetAllActorsOfClass should return an array of that class. Actually, if you use a GetAllActorsOfClass node in blueprints, it does return an array of that class, even though I can’t see any Casting or other conversion in the UGameplayStatics::GetAllActorsOfClass code.

I personally just do

TArray<AMyActor*> MyActors;
for (AActor* actor : OutActors)
{
    MyActors.Add(Cast<MyActor>(actor));
}

But I’d like to know if it’s possible to get an array of the required class right away, just like you can in blueprints.