Thank you very much, this is the correct way to do it.
In you Pawn/Character’s header file, override GetActorEyesViewPoint:
virtual void GetActorEyesViewPoint(FVector& OutLocation, FRotator& OutRotation) const override;
And in the C++ file, I used a socket in the skeletal mesh that pointed forward X in the direction of sight:
void AEnemyCharacter::GetActorEyesViewPoint(FVector& OutLocation, FRotator& OutRotation) const
{
static const FName VisualSense = FName(TEXT(“VisualSense”));
const FTransform ViewTransform = GetMesh()->GetSocketTransform(VisualSense);
OutLocation = ViewTransform.GetLocation();
OutRotation = ViewTransform.GetRotation().Rotator();
}
Confirmed to work in UE5.3.2.