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"));
}