UAIPerceptionComponent (sight) not rotating with AIController/Pawn

I set up a AIPerceptionComponent using sight on my AIController. It’s able to sense all registered stimuli fine and process them via the delegates. One of the stimuli is the player and it follows the player using it. However, while following/moving around, the perceptionComponent doesn’t rotate with the pawn and will continue to face in the original direction.

I’m using a BehaviorTree and MoveTo Task for the AI Movement. If at the map load, I eject out of the player pawn and manually rotate the AICharacter, the perceptionComponent correctly rotates with it.

Is there something that I need to set up in order for it to rotate with the pawn?

I have the same problem with my UAIPerceptionComponent. However I found out that the problem comes from the AIController. I found a work around but I can’t explain you why this works (I’m new in UE4, but not to programming). You need to create a Blueprint class based on the Controller you created then you need to set the Blueprint Controller as the AIControllerClass (the easiest way to attach this is to do this in BP not Cpp).

I hope I could help you :slight_smile:

EDIT:
I solved the Problem by overriding the following function

FRotator MyAIController::GetControlRotation() const
{
	return FRotator(0.0f, GetPawn()->GetActorRotation().Yaw, 0.0f);
}

Now the Controller will always return to the Rotation from the Pawn.
You could achive this by overriding the following function, too

virtual void SetControlRotation(const FRotator& NewRotation);

But in my case the controllers rotation must match the Pawns yaw rotation.

2 Likes

Hey Conan!

Sorry to revive this, but your answer has just saved me. I had tried a lot of rotation combinations between Controller and Actor/CharacterMovement but nothing worked.

Thank you for sharing.

1 Like

I had the same issue
I fixed it by making sure that the AI controller start with tick enabled