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.
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() { Super::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); } }
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-156745 in the post.