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"

PerceptionComponent Sight issue

I, I'm actually trying to create some AI in C++, i'm beginner so I don't know all subtleties of UE C++ Programming. Well, I create a simple AI with PerceptionComponent, like this:

     PerceptionComp = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component"));
     SightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Config"));
     HearingConfig = CreateDefaultSubobject<UAISenseConfig_Hearing>(TEXT("Hearing Config"));
     // Sight Config Settings
     SightConfig->SightRadius = AISightRadius;
     SightConfig->LoseSightRadius = AILoseSightRadius;
     SightConfig->PeripheralVisionAngleDegrees = AIFieldOfView;
     SightConfig->DetectionByAffiliation.bDetectEnemies = true;
     SightConfig->DetectionByAffiliation.bDetectNeutrals = true;
     SightConfig->DetectionByAffiliation.bDetectFriendlies = true;
     // Hearing Config Settings
     HearingConfig->HearingRange = AIHearingRadius;
     HearingConfig->DetectionByAffiliation.bDetectEnemies = true;
     HearingConfig->DetectionByAffiliation.bDetectNeutrals = true;
     HearingConfig->DetectionByAffiliation.bDetectFriendlies = true;
     GetAIPerceptionComponent()->OnPerceptionUpdated.AddDynamic(this, &ADwarfController::OnPawnDetected);

When AI spawn Controller is successfully set,perception and senses too except that in Debuger Tool Sight is pointing to the sky

alt text

And DetectionByAffiliation seems broken too. :/

I tried to inspect every function to discover if any of these affect perception rotation or something, without sucess.

Thanks by advance.

Product Version: UE 4.20
2018-12-05-9.png (702.3 kB)
more ▼

asked Dec 05 '18 at 02:04 PM in C++ Programming

avatar image

1 2

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

1 answer: sort voted first

Alright, that's was my fault, just forgot to add this at GetControlRotation()

 FRotator ADwarfController::GetControlRotation() const
     if (GetPawn() == nullptr) {
         return FRotator(0.0f, 0.0f, 0.0f);
     return FRotator(0.0f, GetPawn()->GetActorRotation().Yaw, 0.0f);

more ▼

answered Dec 06 '18 at 10:30 AM

avatar image

1 2

(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