So, I’m using a single AI Controller that can change which Pawn it is possessing at a given time.
Upon possession, the first pawn behaves as expected, but after unpossessing it and moving to the second Pawn it seems that the Behavior Tree is not reset. I.e, it does not start again from the Root node.
What I’ve tried so far:
- Setting the following AIController variables in constructor:
AMyAIController::AMyAIController()
{
bStartAILogicOnPossess = true;
bStopAILogicOnUnposses = true;
}
- Trying to reset the Brain Component / BT Component in OnPossess
void AMyAIController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
if(BrainComponent)
{
BrainComponent->StopLogic(TEXT("Possessing a new pawn"));
BrainComponent->Cleanup();
BrainComponent->RestartLogic();
}
RunBehaviorTree(BehaviorTree);
}
What am I missing? How can I make the Controller reset the BT execution upon possessing a new Pawn?