APlayerController throws exception, don't know why?

cpp:

{

Super::BeginPlay();




float MouseY = 0.0f;
float MouseX = 0.0f;
FVector Y = FVector(0, 0, 0);
FRotator X = FRotator(0, 0, 0);



	FOnTimelineFloat TimelineProgress;
	TimelineProgress.BindUFunction(this, FName("TimelineProgress"));

	FCurveTimeline.AddInterpFloat(CurveFloat, TimelineProgress);
	FCurveTimeline.SetLooping(true);
	StartLoc = EndLoc = GetActorRotation();
	EndLoc.Yaw * PC->GetControlRotation() * 100;

	FCurveTimeline.PlayFromStart();

}

void AInteractBase::TimelineProgress(float Value)

{
//value between distances

FRotator NewLocation = FMath::Lerp(StartLoc, EndLoc, Value);
SetActorRotation(NewLocation);

}

H file

UFUNCTION()
void TimelineProgress(float Value);

FTimeline FCurveTimeline;
UPROPERTY(EditAnywhere,Category = "Movement")
UCurveFloat* CurveFloat;


UPROPERTY()
	FRotator StartLoc;
UPROPERTY()
	FRotator EndLoc;

UPROPERTY()
APlayerController* PC;


UPROPERTY(EditAnywhere,Category = "Timeline")
	float ZOffset;

Exception thrown at EndLoc.Yaw * PC->GetControlRotation() * 100;

The error: Unhandled exception at 0x00007FFC3A5643DF (UE4Editor-OtherProjectWouldNot.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

Why am I getting this?

I don’t see where you get the Player Controller. From what I see in your code, you only declare it, and it remains nullptr all the time.

On Begin Play, call

PC = Cast<APlayerController>(GetController());

That’s if you use it in your character.

If not, you can #include “Kismet/GameplayStatics.h” and

PC = UGameplayStatics::GetPlayerController(GetWorld(), 0);

That’s what I needed, thanks.