I added in my level many Default Pawns with some code to have them moving around.
With my player controller, I can use a key to own one pawn:
this->Possess(pawn);
this->SetViewTarget(pawn);
But, when I unpossess the pawn, how to restore its previous (default IA Controller)?
this->UnPossess();
So far the only way I found was to save the created controller:
void ACubePawn::BeginPlay()
{
Super::BeginPlay();
// Save the controller
StartController = this->GetController();
}
And then restore it on the UnPossessed method:
void ACubePawn::UnPossessed()
{
Super::UnPossessed();
this->Controller = StartController;
}