UAIPerceptionSystem::UnregisterSource according to its documentation should treat Sense == null as targeting all sources, but the code for removing pending sources does not treat Sense == null as this.

Steps to Reproduce
  1. Add a source actor for multiple sense classes to AIPerceptionSystem with RegisterSource.
  2. In the same frame, call UnregisterSource with Sense == null.

The source is not removed, because the pending pass does not treat Sense == null as targeting all senses.

Expected: The source should be removed. As per the documentation of the function, Sense == null should be treated as targeting all senses.

Code to repro:

void AAISourcesTestActor::BeginPlay()

   UAIPerceptionSystem* PerceptionSystem = UAIPerceptionSystem::GetCurrent(this);
   if (PerceptionSystem)
      PerceptionSystem->RegisterSourceForSenseClass(UAISense_Hearing::StaticClass(), *this);
      PerceptionSystem->RegisterSourceForSenseClass(UAISense_Sight::StaticClass(), *this);
      PerceptionSystem->RegisterSourceForSenseClass(UAISense_Team::StaticClass(), *this);

      // Should remove above pending adds, but does not.
      PerceptionSystem->UnregisterSource(*this, nullptr);

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-156745 in the post.

Login to Vote

ComponentUE - AI - Perception
Affects Versions4.
Target Fix5.2
Fix Commit20688284
Main Commit20688284
CreatedJun 15, 2022
ResolvedFeb 1, 2023
UpdatedMar 15, 2023
View Jira Issue