AI perception: Pawn never loses sight

Hey everyone,

I think I found a bug with the AI Perception system. I have an AI Pawn set up to use sight. When leaving the outer lose sight radius, my perception isn’t updated to inform my AI Controller that the sight has been lost:

void AEnemyAIController::OnTargetPerceptionUpdated(AActor* Actor, FAIStimulus Stimulus)
{
	GEngine->AddOnScreenDebugMessage(-1, 2, FColor::White, FString::Printf(TEXT("Target %s perception updated!"), *Actor->GetName()));
	if(Stimulus.WasSuccessfullySensed())
	{
		GEngine->AddOnScreenDebugMessage(-1, 2, FColor::Cyan, FString::Printf(TEXT("Target %s sensed!"), *Actor->GetName()));    
		SetEnemy(Cast<ASpaceShip>(Actor));
	}
	else
	{
		GEngine->AddOnScreenDebugMessage(-1, 2, FColor::Cyan, TEXT("Target lost..."));    
		SetEnemy(nullptr);
	}
}

I’m only receiving one call to the update method when the player is sensed. This was working in the past. Not sure when but I guess around UE 4.17. I’m registering the method in begin play:

void AEnemyAIController::BeginPlay()
{
	Super::BeginPlay();

	UAIPerceptionComponent* perceptionComponent = GetPerceptionComponent();
	if (ensureMsgf(perceptionComponent, TEXT("Perception component not set, cannot intialize target perception updating")))
	{
		perceptionComponent->OnTargetPerceptionUpdated.AddDynamic(this, &AEnemyAIController::OnTargetPerceptionUpdated);
	}
}

I also recorded a video showing how the AI never loses sight of me: UE 4.19 - AI Perception sight is never lost - YouTube
Is this a bug or did something change and I’m doing it wrong now?

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

https://forums.unrealengine.com/unreal-engine/announcements-and-releases/1410408-unreal-engine-bug-submission-form

Thanks

Hi Jeff A,
thanks for the hint. I’ll take a look at it and will try to reproduce the bug in a new project when I find the time to do so.

I found out what the issue is: I set the auto-success range to 300, thinking this would mean a radius around the enemy where he will always sense the player.

Playing around with this today I noticed my mystake: The auto-success range is relative to the position the player was last seen. So given the maximum speed the player could achieve in my game he was never able to outrun being seen with this high of a value.