APawn::PlayerState: cannot access private member declared in class 'APawn'

I get this on newer versions of UE 4.24, but not on older ones around 4.17.

Do I have to make something public? Do I ever edit the default Pawn.h class?

GameFramework/PawnMovementComponent.h(14): note: see declaration of ‘APawn’
BaseCharacter.cpp(141) : error C2248: ‘APawn::PlayerState’: cannot access private member declared in class ‘APawn’
GameFramework/Pawn.h(131): note: see declaration of ‘APawn::PlayerState’

My BaseCharacter.cpp file

#include "BaseCharacter.h"
#include "TPS2.h"
#include "PlatformerPlayerState.h"
#include "Net/UnrealNetwork.h"
#include "GameFramework/SpringArmComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "Camera/CameraComponent.h"
#include "Components/ArrowComponent.h"
#include "Components/InputComponent.h"
#include "Components/CapsuleComponent.h"
#include "Components/SkeletalMeshComponent.h"
#include "GameFramework/Controller.h"

// Sets default values
    // Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;

    //Set up our springarm to hold our camera
    SpringArm = CreateDefaultSubobject<USpringArmComponent>(FName("Camera Boom"));
    //Do not allow spring arm to rotate with character
    SpringArm->bUsePawnControlRotation = false;
    //Do not allow it to be affected by relative rotation of character
    //Length of arm
    SpringArm->TargetArmLength = 700.f;
    //Attach to root

    //Set up the camera
    Camera = CreateDefaultSubobject<UCameraComponent>(FName("Camera"));
    //Give it a wider FOV
    Camera->FieldOfView = 110.f;
    //attach to SpringArm

    //Set up our forward direction
    TraceDirection = CreateDefaultSubobject<UArrowComponent>(FName("Trace Direction"));
    //attach to root

    //set up basic network replication
    bReplicates = true;
    bAlwaysRelevant = true;
    //bReplicateMovement = true;

    //Set up character movement properties

    //rotate the character in the direction its moving
    GetCharacterMovement()->bOrientRotationToMovement = true;
    //don't rotate based on controller input
    bUseControllerRotationPitch = false;
    bUseControllerRotationRoll = false;
    bUseControllerRotationYaw = false;

    //jump higher
    GetCharacterMovement()->JumpZVelocity = 1000.f;
    //fall faster
    GetCharacterMovement()->GravityScale = 2.f;
    //Allow some control of character while airborne
    GetCharacterMovement()->AirControl = 0.8f;


void ABaseCharacter::MoveForward(float amount)
    //add movement input in the direction the camera is facing
    if (Controller && amount) {
        AddMovementInput(SpringArm->GetForwardVector(), amount);

void ABaseCharacter::MoveRight(float amount)
    if ((Controller != NULL) && (amount != 0.0f))
        // find out which way is right
        const FRotator Rotation = Controller->GetControlRotation();
        const FRotator YawRotation(0, Rotation.Yaw, 0);

        // get right vector
        const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
        // add movement in that direction
        AddMovementInput(Direction, amount);

void ABaseCharacter::RotateCamera(float amount)
    //add rotation on the spring arm's z axis
    if (Controller && amount) {
        FVector rot = SpringArm->GetComponentRotation().Euler();
        rot += FVector(0, 0, amount);

void ABaseCharacter::ChangeCameraHeight(float amount)
    //add rotation on spring arm's y axis. Clamp between -45 and -5
    if (Controller && amount) {
        FVector rot = SpringArm->GetComponentRotation().Euler();

        float originalHeight = rot.Y;
        originalHeight += amount;
        originalHeight = FMath::Clamp(originalHeight, -45.f, -5.f);

        rot = FVector(0, originalHeight, rot.Z);

void ABaseCharacter::CollectCoin()
    APlatformerPlayerState *PS = Cast<APlatformerPlayerState>(PlayerState);

    if (PS) {

// Called when the game starts or when spawned
void ABaseCharacter::BeginPlay()
    //set the spring arm behind our character
    SpringArm->SetRelativeRotation(FQuat::MakeFromEuler(FVector(0, -25, 180)));

// Called every frame
void ABaseCharacter::Tick(float DeltaTime)


// Called to bind functionality to input
void ABaseCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)

    //Bind inputs
    InputComponent->BindAction("Jump", EInputEvent::IE_Pressed, this, &ACharacter::Jump);

    InputComponent->BindAxis("ChangeCameraHeight", this, &ABaseCharacter::ChangeCameraHeight);
    InputComponent->BindAxis("RotateCamera", this, &ABaseCharacter::RotateCamera);
    InputComponent->BindAxis("MoveForward", this, &ABaseCharacter::MoveForward);
    InputComponent->BindAxis("MoveRight", this, &ABaseCharacter::MoveRight);

Use GetPlayerState()

void ABaseCharacter::CollectCoin()
    APlatformerPlayerState *PS = GetPlayerState<APlatformerPlayerState>();
    if (PS) {

Wow nice it worked. Thanks.