Hi,
I have been trying to configure the AI in C++ and have been successfull in the most part. I’m stuck now at using the perception component. I have configured the sense config and if i use in MyAIController
EvilPerception->OnPerceptionUpdated.AddDynamic(this, &AEvilMind::ChaseAndShoot);
This works with the ChaseAndShoot defined as
UFUNCTION()
void ChaseAndShoot(TArray<AActor*> actors);
So far so good. What i really wanted to use was OnTargetPerceptionUpdated and looking through various header files e.g AIPerceptionComponent.h, i figured that the delegate function will need to have and Actor*, FAIStimulus as it’s parameters, which is what is available from BP’s. But i keep getting compile errors. What i’ve used:
MyAIController.h
UFUNCTION()
void ChaseAndShoot(AActor* actor, FAIStimulus stimulus);
MyAIController.cpp
EvilPerception->OnTargetPerceptionUpdated.AddDynamic(this, &AEvilMind::ChaseAndShoot);
and:
void AEvilMind::ChaseAndShoot(AActor* actor, FAIStimulus stimulus) {
UE_LOG(LogClass, Warning, TEXT("Sight Triggered"));
}
But this does not compile. As far as i can understand it is not recognising FAIStimulus, i think that was the error, if i compiled from the editor
I did some googling already and could find but one post that was about a problem with OnTargetPerceptionUpdated but the errors didnt seems similar anywho, the user seemed to have fixed this by including Perception/AIPerceptionTypes.h in the header, i tried that (before the .generated file) but that renders MyAIController.h with a bucket load of errors, and there are squiggly things under the UCLASS() declaration and the class keyword and the first error in the long list is no storage class defined and missing semicolon etc…
I was really hoping to know what is going on and how i can get rid of the error and be able to use OnTargetPerceptionUpdated, that will give me access to the stimuli and the other related functionality defined in the structure that would be quite usefull…
Thanks in advance.