Hi,
i’m trying to delegate OnPerceptionUpdated to my custom function and am not able to use the AddDynamic makro.
MyAIController.h
UPROPERTY(VisibleAnywhere, Category = "MyAIController|Perception")
class UAIPerceptionComponent* PercComp;
UPROPERTY(EditDefaultsOnly, Category = "MyAIController|Perception")
class UAISenseConfig_Sight* SightCfgComp;
UFUNCTION()
void ProcessPerceivedInformation(TArray<AActor*> UpdatedActors);
MyAIController.cpp
AMyAIController::AMyAIController(const FObjectInitializer& ObjectInitializer)
:Super(ObjectInitializer)
{
PercComp = ObjectInitializer.CreateDefaultSubobject<UAIPerceptionComponent>(this, TEXT("MyPercComp"));
SightCfgComp = ObjectInitializer.CreateDefaultSubobject<UAISenseConfig_Sight>(this, TEXT("MySightCfgComp"));
if (PercComp && SightCfgComp) {
PercComp->ConfigureSense(*SightCfgComp);
PercComp->SetDominantSense(SightCfgComp->GetSenseImplementation());
SightCfgComp->SightRadius = 2000.0f;
SightCfgComp->LoseSightRadius = 2200.0f;
SightCfgComp->PeripheralVisionAngleDegrees = 90.0f;
SightCfgComp->DetectionByAffiliation.bDetectEnemies = true;
SightCfgComp->DetectionByAffiliation.bDetectFriendlies = true;
SightCfgComp->DetectionByAffiliation.bDetectNeutrals = true;
}
GetPercComp()->OnPerceptionUpdated.AddDynamic(this, &AMyAIController::ProcessPerceivedInformation);
}
void AMyAIController::ProcessPerceivedInformation(TArray<AActor*> UpdatedActors) {
}
Does anyone spot my error ?