PerceptionComponent Sight issue

I, I’m actually trying to create some AI in C++, i’m beginner so I don’t know all subtleties of UE C++ Programming.
Well, I create a simple AI with PerceptionComponent, like this:

	PerceptionComp = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component"));

	SightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Config"));
	HearingConfig = CreateDefaultSubobject<UAISenseConfig_Hearing>(TEXT("Hearing Config"));

	SetPerceptionComponent(*PerceptionComp);

	// Sight Config Settings
	SightConfig->SightRadius = AISightRadius;
	SightConfig->LoseSightRadius = AILoseSightRadius;
	SightConfig->PeripheralVisionAngleDegrees = AIFieldOfView;
	SightConfig->SetMaxAge(AISightAge);

	SightConfig->DetectionByAffiliation.bDetectEnemies = true;
	SightConfig->DetectionByAffiliation.bDetectNeutrals = true;
	SightConfig->DetectionByAffiliation.bDetectFriendlies = true;

	// Hearing Config Settings
	HearingConfig->HearingRange = AIHearingRadius;
	HearingConfig->SetMaxAge(AIHearingAge);

	HearingConfig->DetectionByAffiliation.bDetectEnemies = true;
	HearingConfig->DetectionByAffiliation.bDetectNeutrals = true;
	HearingConfig->DetectionByAffiliation.bDetectFriendlies = true;

	GetAIPerceptionComponent()->SetDominantSense(*SightConfig->GetSenseImplementation());
	GetAIPerceptionComponent()->OnPerceptionUpdated.AddDynamic(this, &ADwarfController::OnPawnDetected);
	GetAIPerceptionComponent()->ConfigureSense(*SightConfig);
	GetAIPerceptionComponent()->ConfigureSense(*HearingConfig);

When AI spawn Controller is successfully set,perception and senses too except that in Debuger Tool Sight is pointing to the sky

And DetectionByAffiliation seems broken too. :confused:

I tried to inspect every function to discover if any of these affect perception rotation or something, without sucess.

Thanks by advance.

Alright, that’s was my fault, just forgot to add this at GetControlRotation()

FRotator ADwarfController::GetControlRotation() const
{
	if (GetPawn() == nullptr) {
		return FRotator(0.0f, 0.0f, 0.0f);
	}
	return FRotator(0.0f, GetPawn()->GetActorRotation().Yaw, 0.0f);
}