Casting AActor to pawn

I am getting an AActor array of my AITanks. I then try looping through the array getting my AITanks setting them to a TempAITank and then casting from that tank to get the controller.

The issue is that the “GetController()” method is not apart of the AAcotor Class. But when changing my pointer from “AActor* TempAITank;” to “APawnAITank* TempAITank;” I get the error “Can not convert AActor to APawnAITank”

So is there a way to convert my AActors to APawnAITank? Or is there a way to an Array of my pawns from the scene, in my created game mode?

You’ve declared the TArray on line 67 as AActor which doesn’t match the APawnAITank* TempAITank when you try to assign it.

I’m 99% sure that if you change the TArray, you won’t need to cast since it will definitely be a type of APawnAITank and can go straight to line 76 with:
TankAIControllerRef = Cast(AITank[i]->GetController());

When I change line 67 to be APawnAITank* I get the error on line 68 because it wants an AActor array. not an APawnAITank array and it can not convert it.

UGameplayStatics::GetAllActorsOfClass(GetWorld(), APawnAITank::StaticClass(), AllActors);
for (AActor* Actor : AllActors)
APawnAITank* AITank = Cast(Actor);
// …

Parameter signature of UGameplayStatics::GetAllActorsOfClass()

(const UObject* WorldContextObject, TSubclassOf<AActor> ActorClass, TArray<AActor*>& OutActors)

OutActors has to be TArray<AActor*>.