x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

OnPerceptionUpdated.AddDynamic doesn't work

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 ?

Product Version: UE 4.20
Tags:
more ▼

asked Nov 06 '18 at 09:10 PM in C++ Programming

avatar image

5v29n
56 12 15 19

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hi 5v29n,

The OnPerceptionUpdated event takes a const reference to an array of actors ( const TArray<AActor*>& ), whereas your code is simply an array. If you change the parameter that should fix your compile error.

more ▼

answered Nov 06 '18 at 10:26 PM

DarkwindRichard (suspended)
avatar image 5v29n Nov 06 '18 at 11:04 PM

Lol. I thought i tried it already that way. Obviously i was wrong. Thank you DarkwindRichard and Epic !

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question