AI Perception Component not Rotating with Character

I faced a similar issue while programming my custom controller a while back.

It took a bit of finding, but I was able to rectify the issue by overriding the AController::GetControlRotation() function.

In your .h class you would put

virtual FRotator GetControlRotation() const override;

And in your .cpp file you’d have something like so

FRotator AIPatrolController::GetControlRotation() const
{
	if (GetPawn() == nullptr)
	{
		return FRotator();
	}

	return FRotator(0.0f, GetPawn()->GetActorRotation().Yaw, 0.0f);
}

Hope this helps.

1 Like