I think you need to set up senses for the component, here is how i did it in my AI controller maybe it can help you.
.h
virtual void ActorsPerceptionUpdated(const TArray<AActor*>& UpdatedActors);
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "AI")
UAISenseConfig_Sight *sightConfig;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "AI")
UAIPerceptionComponent *aiPerception;
.cpp
AUnitAIController::AUnitAIController(const FObjectInitializer &ObjInit)
{
aiPerception = GetAIPerceptionComponent();
aiPerception = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("AIPerception Component"));
sightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Config"));
sightConfig->DetectionByAffiliation.bDetectEnemies = true;
sightConfig->DetectionByAffiliation.bDetectNeutrals = true;
sightConfig->DetectionByAffiliation.bDetectFriendlies = true;
aiPerception->ConfigureSense(*sightConfig);
}
void AUnitAIController::ActorsPerceptionUpdated(const TArray<AActor*>& UpdatedActors)
{
for (AActor *actor : UpdatedActors)
{
//do something
}
}
The ActorsPerceptionUpdated is only called when something is changed (when characters enters or leaves your perception).