My 2 cents here: AI perception’s sight is influenced by your “senser’s” eye height. If you’ve put AIPerception on a Controller (AIController), it will go & check its controlled pawn’s eye height for the line traces it needs to do in order to detect things in the game world. Likewise, if you’ve put your AI perception component on the pawn itself (which is discouraged btw), it’s going to check the pawn’s pre-configured eyesight value. So make sure that your pawn’s eyesight is set up correctly.
Also, the AIPerception component only seems to update sight-related info upon sensing / un-sensing something, so you won’t be getting continuous updates after the initial sensing had occurred (via OnPerceptionUpdated and/or OnTargetPerceptionUpdated).
Take a look at AIPerceptionComponent.cpp’s line 359 where you’ll see how the perception system is getting the start location for doing its line traces later:
void UAIPerceptionComponent::GetLocationAndDirection(FVector& Location, FVector& Direction) const
{
const AActor* OwnerActor = Cast<AActor>(GetOuter());
if (OwnerActor != nullptr)
{
FRotator ViewRotation(ForceInitToZero);
OwnerActor->GetActorEyesViewPoint(Location, ViewRotation); // ----> THIS RIGHT HERE!
Direction = ViewRotation.Vector();
}
}
Then, if you look at Controller.cpp’s line 533, you can see how the controller is obtaining the eyes’ viewpoint by forwarding the call to the pawn being controlled:
void AController::GetActorEyesViewPoint( FVector& out_Location, FRotator& out_Rotation ) const
{
// If we have a Pawn, this is our view point.
if ( Pawn != NULL )
{
Pawn->GetActorEyesViewPoint( out_Location, out_Rotation );
}
// otherwise, controllers don't have a physical location
}
Therefore, it’s important to configure your pawn’s eye-height correctly, as otherwise the ground (landscape) may block your perception system’s line traces from reaching other actors:
Note that as an edge-case you may also discover that your perception component’s OnTargetPerception and/or OnPerceptionUpdated events get called very frequently, with the “Successfully Sensed” boolean alternating between true and false. This is also a result of incorrect eye-height settings.
Hope this helps!