Cannot take class inherited from actor into a function asking for actor.

I’ve written a function that finds an average location from an array of actors. I need to pass a class inherited from actor (like a unit, that extends ACharacter). Compiler gives error - unable to convert.

I think this may be like a rookie c++ problem. I don’t have formal C++ training so I’m not sure if there is a special syntax to enable passing children into a function.


FVector ASPlayerController::GetAverageActorLocation(const TArray<AActor*> ActorArray) const
{
    FVector AddedLocations(0.0f);

    for (AActor* CurrentActor : ActorArray)
    {
        AddedLocations += CurrentActor->GetActorLocation();
    }

    FVector AverageLocation = AddedLocations / ActorArray.Num();
    return AverageLocation;
}

Thanks!