Detect when AI Perception loses sight of the player?

This helped me a lot. In case someone needs it in c++ :

 FActorPerceptionBlueprintInfo Info;
    				GetAIPerceptionComponent()->GetActorsPerception(PlayerPawn, Info);
    				
    				if (Info.LastSensedStimuli.Num() > 0) {
    					const FAIStimulus Stimulus = Info.LastSensedStimuli[0];
    
    					if (Stimulus.WasSuccessfullySensed()) {
    						//Player in sight
    					}
    					else {
    						//Player out of sight
    					}
    				}
2 Likes