This cause the issue of finding the wrong tank.
ATank* ATankAIController::GetPlayerTank() const
{
auto PlayerPawn = GetWorld()->GetFirstPlayerController()->GetPawn();
if (!PlayerPawn) { return nullptr; } // Note the !, very important
return Cast<ATank>(PlayerPawn);
}
https://github.com/randomwangran/cpp/blob/988cab4f10322ef0052d0dc5c7fd6860006d86d0/Unreal/Section04/Source/BattleTank/TankAIController.cpp#L41-L45
This cause the issue of finding the wrong tank.