Hi, we just migrated from 4.10 to 4.11 and i used the following code in 4.10 to spawn the controllers ( I had to spawn them because we had multiple characters to switch between )
FoxController = Cast<AAnimalAIController>( GetWorld()->SpawnActor(AAnimalAIController::StaticClass()));
WolfController = Cast<AAnimalAIController>(GetWorld()->SpawnActor(AAnimalAIController::StaticClass()));
for (TActorIterator<AAryaController> FoxCIter(GetWorld()); FoxCIter; ++FoxCIter)
{
AryaController = Cast<AAryaController>(*FoxCIter);
}
for (TActorIterator<ACameraDirector> FoxCIter(GetWorld()); FoxCIter; ++FoxCIter)
{
CameraDirector = Cast<ACameraDirector>(*FoxCIter);
}
EnableInput(GetWorld()->GetFirstPlayerController());
InputComponent->BindAction("Wolf", IE_Released, this, &ACameraManager::PossessWolf);
InputComponent->BindAction("Fox", IE_Released, this, &ACameraManager::PossessFox);
InputComponent->BindAction("Fox_Distract", IE_Released, this, &ACameraManager::FoxDistract);
for (TActorIterator<AWolf> WolfIter(GetWorld()); WolfIter; ++WolfIter)
{
Wolf = *WolfIter;
}
for (TActorIterator<AFox> FoxIter(GetWorld()); FoxIter; ++FoxIter)
{
Fox = *FoxIter;
}
for (TActorIterator<AArya> AryaIter(GetWorld()); AryaIter; ++AryaIter)
{
CameraDirector->Arya = *AryaIter;
Arya = *AryaIter;
}
PossessWolf();
AryaController->Possess(Arya);
}
void ACameraManager::PossessWolf()
{
Wolf->PossessByPlayer();
FoxController->Possess(Fox);
CameraDirector->SetCurrentAnimal(Wolf);
AryaController->CurrentAnimal = Wolf;
Arya->CurrentAnimal = Wolf;
}
void ACameraManager::PossessFox()
{
Fox->PossessByPlayer();
WolfController->Possess(Wolf);
CameraDirector->SetCurrentAnimal(Fox);
AryaController->CurrentAnimal = Fox;
Arya->CurrentAnimal = Fox;
}
The possess function of the controllers :
void AAnimalAIController::Possess(APawn* InPawn)
{
Super::Possess(InPawn);
CurrentAnimal = Cast<AChild_No_More_1Character>(InPawn);
CurrentAnimal->AmITheOwner = false;
if (CurrentAnimal)
{
CurrentAnimal->MyController = Cast<AAIController>(this);
MyBlackBoard->InitializeBlackboard(*(CurrentAnimal->MyTree->BlackboardAsset));
MyBlackBoard->SetValueAsObject("Arya", CurrentAnimal->Arya);
MyBlackBoard->SetValueAsObject("SelfActor", CurrentAnimal);
MyTree->StartTree(*(CurrentAnimal->MyTree));
}
}
This code worked perfectly in 4.10 but in 4.11, the characters just stand there.