I saw this code in project EpicSurvivalGameSeries
void ASGameMode::SpawnNewBot()
{
FActorSpawnParameters SpawnInfo;
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
ASZombieAIController* AIC = GetWorld()->SpawnActor<ASZombieAIController>(SpawnInfo);
RestartPlayer(AIC);
}
void ASZombieAIController::Possess(class APawn* InPawn)
{
Super::Possess(InPawn);
ASZombieCharacter* ZombieBot = Cast<ASZombieCharacter>(InPawn);
if (ZombieBot)
{
if (ZombieBot->BehaviorTree->BlackboardAsset)
{
BlackboardComp->InitializeBlackboard(*ZombieBot->BehaviorTree->BlackboardAsset);
/* Make sure the Blackboard has the type of bot we possessed */
SetBlackboardBotType(ZombieBot->BotType);
}
BehaviorComp->StartTree(*ZombieBot->BehaviorTree);
}
}
I debug with these code, I found that when invoke RestartPlayer(AIC);, it will trigger function ASZombieAIController::Possess(class APawn InPawn)*, I can understand this, but what I can’t understand is that an Pawn ASZombieCharacter assign to InPawn which is parameter of ASZombieAIController::Possess(), and I didn’t find any handle about this assigning in project.