OnPerceptionUpdated Detecting Dead Actor

Hi I have a following Case

There are three AI candidates. In team one there is one AI and in team 2 there are two AI candidates. Initially AI of team 1 senses both AI of team 2 using OnPerceptionUpdated after AI of Team 1 kills one of the AI of Team2 then on printing I get name of AI who got dead in other words I am not getting AI who is still in the sight instead I get the AI who was killed and destroyed.Following is my sample code.

void AAIController::BeginPlay()
 {
	Super::BeginPlay();
    //Function that will be called When Perception Updates
    AIPerception->OnPerceptionUpdated.AddDynamic(this, &AIController::SenseAllActors);

  }
    
    void AAIController::SenseAllActors(const TArray<AActor*>& detectedActors)
    {

    	for (auto act : detectedActors)
    		UE_LOG(LogTemp, Warning, TEXT("I %s detected %s"), *GetPawn()->GetName(), *act->GetName());
    
    }

What about detectedActors? bestActors is used in range loop.

Sorry I pasted selected portion of code to avoid confusion I have updated accordingly.

I solved by using GetCurrentlyPerceivedActors method which detects all the actor in the radius and on passing nullptr it will select actors for all senses.

void AAIController::SenseAllActors(const TArray<AActor*>& detectedActors)
{
	UE_LOG(LogTemp, Warning, TEXT("I am sensing"));
	TArray<AActor*> sensedActors;
	AIPerception->GetCurrentlyPerceivedActors(nullptr, sensedActors);
}