[Help]Character rotation problems

I want to write a function in UE5.6.0 to make the character look at the player character, but it seems to be causing issues. What’s going wrong?

There are my header files and that function(In UE5.6.0):

include “StdChar_Enemy.h”
include “GameFramework/CharacterMovementComponent.h”
include “GameFramework/Actor.h”
include “Debug/DebugDrawService.h”
include “Engine/World.h”
include “Kismet/KismetMathLibrary.h”
include “Kismet/GameplayStatics.h”

void AStdChar_Enemy::LookAtPlayer(const AActor* TargetActor) const
{
if (CanSeeActor(TargetActor))
{
return;
}
FRotator LookAtRotation = UKismetMathLibrary::FindLookAtRotation(GetActorLocation(), TargetActor->GetActorLocation());

SetActorRotation(LookAtRotation);    //The code that caused the error  :(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


DrawDebugLine(GetWorld(), GetActorLocation(), TargetActor->GetActorLocation(), FColor::Green, false, 0.1f);

GetCharacterMovement()->bUseControllerDesiredRotation = true; // Use controller rotation for smooth turning
GetCharacterMovement()->bUseControllerDesiredRotation = true; // Use controller rotation for smooth turning
GetCharacterMovement()->RotationRate = FRotator(0.0f, 720.0f, 0.0f); // Set rotation rate for smooth turning
GetCharacterMovement()->bOrientRotationToMovement = false; // Disable orienting to movement

}