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"

AI Perception (C++) Not Firing

I have already read the Quick AI Perception Guide and surfed through all the tutorials regarding how to set up the AI Perception in C++. Nothing seems to work.

I have managed to only make it work on Blueprint but NOT in C++.

Below is my code:

BaseCharacter.h // Custom Class

 UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = Senses)
 class UAIPerceptionComponent* PerceptionComponent;
 UPROPERTY(BlueprintReadWrite, Category = Senses)
 class UAISenseConfig_Sight* SightConfig;
 void UpdatePerception(TArray<AActor*>ActorsInSight);


     // ....
     PerceptionComponent = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("AI Perception Component"));
     SightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("AI Sight Config"));
     PerceptionComponent->OnPerceptionUpdated.AddDynamic(this, &ABaseCharacter::UpdatePerception);
     SightConfig->SightRadius = 2000.f;
     SightConfig->LoseSightRadius = 2000.f + 20.f;
     SightConfig->PeripheralVisionAngleDegrees = 90.0f;
     SightConfig->DetectionByAffiliation.bDetectEnemies = true;
     SightConfig->DetectionByAffiliation.bDetectFriendlies = true;
     SightConfig->DetectionByAffiliation.bDetectNeutrals = true;
 void ABaseCharacter::UpdatePerception(TArray<AActor*>ActorsInSight)
     GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Red, TEXT("UPDATE PERCEPTION"));

Product Version: UE 4.12
more ▼

asked Jul 04 '16 at 04:25 PM in C++ Programming

avatar image

1 2 4

avatar image Ephemera_Devel Jul 04 '16 at 09:16 PM

I have fixed the problem.

avatar image PhoenixFalcon Aug 19 '16 at 05:51 PM

Hi, could you please tell how did you fixed it? I am having exactly the same problem.

avatar image virtual_nomak Mar 16 '17 at 11:18 PM

What did you do to fix this?

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

2 answers: sort voted first

Its like because pivot point is below surface.

more ▼

answered Sep 03 '16 at 08:01 AM

avatar image

0 1 4

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

U have first SetPerceptionComponent inside the AI Controller class, as there is a default PerceptionComponent within AI Controller. Then, use GetAIPerceptionComponent()->OnPerceptionUpdated.AddDynamic( paramaters ) instead of the AIPerceptionComponent that u constructed by urself. I stucked at this for hours, and finally figure that out by accident.

Hope this message is useful. Cheers. UE 4.16

more ▼

answered Aug 17 '17 at 05:01 PM

avatar image


(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