I need Event On Possess , in c++?

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 …)

Thanks.
MSD.

Hi,

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
    // ...
}

The Bluepint event will be called as well.

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;

See this question: OnPossess not overrideable in AIController - Programming & Scripting - Unreal Engine Forums

Might I also suggest looking at the BeginPlayingState() function.

It seems to be called immediately following possession, but is empty and thus safe to override.