# AIPerceptionComponent in C++ does not display "Detection by affiliation"

**URL:** <https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196>\
**Category:** Blueprint\
**Tags:** Perception, unreal-engine, Blueprint, CPP, question\
**Created:** [March 29, 2016, 11:02pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196 "2016-03-29T23:02:31Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emidee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emidee](https://forums.unrealengine.com/u/Emidee)\
**Post date:** [March 29, 2016, 11:02pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/1 "2016-03-29T23:02:31Z")

</div>

Hi,

When I add the AIPerceptionSystemComponent in the BluePrint editor, and add a sense to the SensesConfig, the DetectionByAffiliation is correctly displayed : it is expanded, and I can check the 3 checkboxes.

 ![84289-2016-03-30+00_51_09-bp_aicontroller_.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/a/6ba5dbeb61de18bd0fb9993706b6d1bdf0719a0a.png)

But when I create the perception system in C++, the DetectionByAffiliation is not expandable, and I can’t change the value. More importantly, even changing the values in code doesn’t seem to be reflected at runtime. When I use the blueprint version, and log some text in the event called when the perception is updated, I have some logs.  
Using the same settings in the C++ version, nothing is displayed, because the affiliation check fails in FAISenseAffiliationFilter::ShouldSenseTeam in the Update function of UAISense\_Hearing for example.

 ![84290-2016-03-30+00_58_15-bp_aicontroller_2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/2/b/42b6c8dd1809c4336af77d9678992d07cec5e4f6.png)

Here is the code I use in C++ to configure all that stuff:

```
ARWCAIController::ARWCAIController( const FObjectInitializer& ObjectInitializer )
    : Super( ObjectInitializer )
{
    BlackBoardComponent = CreateDefaultSubobject< UBlackboardComponent >( TEXT( "BlackBoardComp" ) );
    BehaviourTreeComponent = CreateDefaultSubobject< UBehaviorTreeComponent >( TEXT( "BehaviourTreeComp" ) );
    
    SetPerceptionComponent( *CreateDefaultSubobject< UAIPerceptionComponent >( TEXT( "PerceptionComp" ) ) );
    SightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>( TEXT( "Sight Config" ) );

    SightConfig->SightRadius = 300.0f;
    SightConfig->PeripheralVisionAngleDegrees = 360.0f;
    SightConfig->DetectionByAffiliation.bDetectEnemies = true;
    SightConfig->DetectionByAffiliation.bDetectFriendlies = true;
    SightConfig->DetectionByAffiliation.bDetectNeutrals = true;

    GetPerceptionComponent()->ConfigureSense( *SightConfig );
    GetPerceptionComponent()->SetDominantSense( SightConfig->GetSenseImplementation() );

    HearingConfig = CreateDefaultSubobject<UAISenseConfig_Hearing>( TEXT( "Hearing Config" ) );
    HearingConfig->DetectionByAffiliation.bDetectEnemies = true;
    HearingConfig->DetectionByAffiliation.bDetectFriendlies = true;
    HearingConfig->DetectionByAffiliation.bDetectNeutrals = true;

    GetPerceptionComponent()->ConfigureSense( *HearingConfig );

    GetPerceptionComponent()->OnPerceptionUpdated.AddDynamic( this, &ARWCAIController::OnSightPerceptionUpdated );
}

```

Note that I tried to not create the sense config objects in code and add them in the Editor, but the same problem remains…

Is this a bug, or is it me not correctly initializing the component?

Thanks!

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [March 30, 2016, 1:18pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/2 "2016-03-30T13:18:51Z")

</div>

Hello Zoubi,

I have investigated this issue and discovered that it is a known issue (UE-18378). Thank you for your report. I will update the bug report with this post.

Have a great day

---

<div class="post-metadata">

**Author:** ![Emidee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emidee](https://forums.unrealengine.com/u/Emidee)\
**Post date:** [March 30, 2016, 1:24pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/3 "2016-03-30T13:24:02Z")

</div>

Thank you for your answer 🙂

Do we have access to your ticket report system? This would have allowed me to not post here if I has found the bug was already reported

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [March 30, 2016, 1:27pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/4 "2016-03-30T13:27:25Z")

</div>

We currently do not have a way for the public to track our bug reports.

If you are ever wondering if an issue has been reported, however, you can perform a search on [Unreal Engine 4 Documentation | Unreal Engine Documentation](https://docs.unrealengine.com/latest/INT/)

This will allow you to search the documentation, forums, Answerhub, and wiki for information regarding your issue.

Have a great day

---

<div class="post-metadata">

**Author:** ![Ryan\_Darcey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ryan\_Darcey](https://forums.unrealengine.com/u/Ryan_Darcey)\
**Post date:** [July 13, 2016, 4:22pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/5 "2016-07-13T16:22:07Z")

</div>

This is a gnarly bug! Any chance it’s been fixed?

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [July 13, 2016, 4:36pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/6 "2016-07-13T16:36:02Z")

</div>

This issue is still being investigated by our developers, however, there is no timeline for when a fix will be released at this time.

---

<div class="post-metadata">

**Author:** ![Vrtual](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vrtual/32/1025445_2.png) [@Vrtual](https://forums.unrealengine.com/u/Vrtual)\
**Post date:** [March 16, 2017, 11:25pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/7 "2017-03-16T23:25:27Z")

</div>

Hello I just encountered the same issue with the newest release 4.15, is there any workaround to this?

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [March 17, 2017, 1:15pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/8 "2017-03-17T13:15:41Z")

</div>

Hey nullbot,

You can track the issue’s status using the link below: [Unreal Engine Issues and Bug Tracker (UE-18378)](https://issues.unrealengine.com/issue/UE-18378)

Currently, I’m not aware of any known workarounds.

Have a great day

---

<div class="post-metadata">

**Author:** ![Emidee](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emidee](https://forums.unrealengine.com/u/Emidee)\
**Post date:** [March 17, 2017, 5:25pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/9 "2017-03-17T17:25:20Z")

</div>

I added the component in the blueprint directly, and in code I call GetPerceptionComponent() instead of using directly the pointer. That is the only workaround I found

---

<div class="post-metadata">

**Author:** ![wingedrobin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wingedrobin](https://forums.unrealengine.com/u/wingedrobin)\
**Post date:** [February 27, 2018, 2:59am UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/10 "2018-02-27T02:59:25Z")

</div>

Sorry about bump this thread up. I found this issue had been add a fix commit and last updated was at Jan 25, 2018. Is that means the issue had been solved? If yes, will the commit be merged into 4.19?

---

<div class="post-metadata">

**Author:** ![Sean\_Flint](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sean\_Flint](https://forums.unrealengine.com/u/Sean_Flint)\
**Post date:** [March 14, 2018, 4:11am UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/11 "2018-03-14T04:11:46Z")

</div>

At this time the ticket is still unresolved. Those fix commits are from a previous version of the fix that ended up needing to be re-evaluated. Once a new fix version is available, it will appear on the public ticket.

---

<div class="post-metadata">

**Author:** ![Gr1m1cu5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gr1m1cu5](https://forums.unrealengine.com/u/Gr1m1cu5)\
**Post date:** [June 18, 2019, 2:26pm UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/12 "2019-06-18T14:26:59Z")

</div>

I was surprised to discover how long this has been a bug. I did find a decent workaround you can do get it populated in the editor. First, temporarily add another AIPerceptionComponent to your Controller Blueprint. The editor added one will have Detection as Affiliation populated, you can set it however you like. Once you’ve done that, if you right click and pick copy, you can then go to the inherited one and right click on ‘Detection as Affliation’ and pick paste. It will copy those values into it. The underlying struct is still there, just the Editor UI is busted. After you paste it over, you can just delete the one you added. You could even keep it pasted in a text file and keep it that way if you don’t like adding fake components constantly. If you want to inspect what is already set, you can copy it and paste it into a text file to check the values.

---

<div class="post-metadata">

**Author:** ![biubiuty3](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/biubiuty3/32/88719_2.png) [@biubiuty3](https://forums.unrealengine.com/u/biubiuty3)\
**Post date:** [July 11, 2019, 2:50am UTC](https://forums.unrealengine.com/t/aiperceptioncomponent-in-c-does-not-display-detection-by-affiliation/352196/13 "2019-07-11T02:50:39Z")

</div>

On July 10, 2019, this problem remains unsolved, in UE 4.22.3.
