AddDynamic not working with AI Perception Component

I’m trying to add a delegate to OnPerceptionUpdated for an AI controller, using AddDynamic. However, when compiling I keep running into the same error:

error C2664: 'void TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,TArray<AActor *,FDefaultAllocator>>::__Internal_AddDynamic<AEnemyAIController>(UserClass *,void (__cdecl AEnemyAIController::* )(TArray
<AActor *,FDefaultAllocator>),FName)': cannot convert argument 2 from 'void (__cdecl AEnemyAIController::* )(bool,const FHitResult &)' to 'void (__cdecl AEnemyAIController::* )(TArray<AActor *,FDefaultAllocator>)'
         with
         [
             UserClass=AEnemyAIController
         ]

Am I missing something on my code to make AddDynamic work? Here’s the line in EnemyAIController.cpp where I call it:

GetAIPerceptionComponent()->OnPerceptionUpdated.AddDynamic(this, &AEnemyAIController::OnSense);

And this is the test function it calls, that just prints a message to verify it works:

void AEnemyAIController::OnSense(bool FromSweep, const FHitResult& SweepResult)
{
	GEngine->AddOnScreenDebugMessage(FMath::Rand(), 5.f, FColor::Yellow, FString("Enemy sensed something"));
}

Functions you want to bind to a delegate must match delegate’s signature. Look at OnPerceptionUpdated's declaration. It’s using following delegate type:

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPerceptionUpdatedDelegate, TArray, UpdatedActors);

so the function you want to bind to OnPerceptionUpdated needs to take just one argument of type TArray.

Cheers,

–mieszko