Im trying to extend my MyAIController with UAISenseConfig_Hearing sense, but for some reason, the Perceprion system wont use it. My setup is following:
[MyAIcontroller.h]
...
MyAIController(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
UAISenseConfig_Sight* sightConfig;
UAISenseConfig_Hearing* hearingConfig;
UPROPERTY(BlueprintReadOnly, Category = "Components" )
UAIPerceptionComponent* PerceptionComp;
...
[MyAIcontroller.cpp]
MyAIController::MyAIController(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UCrowdFollowingComponent
``(TEXT(“PathFollowingComponent”)))
{
PerceptionComp = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("AIPerception Component"));
sightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Config"));
hearingConfig = CreateDefaultSubobject<UAISenseConfig_Hearing>(TEXT("Hearing Config"));
ConfigereSightParameters(sightConfig);
PerceptionComp->ConfigureSense(*sightConfig);
hearingConfig->DetectionByAffiliation.bDetectEnemies = true;
hearingConfig->DetectionByAffiliation.bDetectFriendlies = true;
hearingConfig->DetectionByAffiliation.bDetectNeutrals = true;
hearingConfig->HearingRange = 650;
PerceptionComp->ConfigureSense(*hearingConfig);
PerceptionComp->SetDominantSense(sightConfig->GetSenseImplementation());
PerceptionComp->OnTargetPerceptionUpdated.AddDynamic(this, &MyAIController ::TargetUpdate);
}
I was using the controller for my AI for a while now(Sight was working correctly). The PerceptionComponent doesnt register the Hearing at all.
][2]
Can anyone know what could be wrong? Funny thing is, that when I create the same thing in Blueprint and just add the sense to AIPerception, it just works!