Hi Guys;
In AI-Controller Blueprint, there is an event called “Event On Possess”. I would like to an equivalent of this event in C++ , please.
Actually, I need this event body in cpp , to put the codes (Like MoveToLocation and so on …)
I guess you could override the Possess function of the AIController because is declared virtual (see docs). I didn’t test it but looking at the code, this should work:
void AMyAIController::Possess(APawn* InPawn)
{
Super::Possess(InPawn);
// your "OnPossess" code here
// ...
}
Apart from the Possess function which might be dangerous because you cut cut the posses logic not calling the super etc you can use SetPawn, which is called by the engine when possessing / unpossessing:
/** Setter for Pawn. Normally should only be used internally when possessing/unpossessing a Pawn. */
virtual void SetPawn(APawn* InPawn) override;