Access Violation error in BeginPlay, nullptr help?

I’ve been following along with an online class teaching how to make a third person shooter, and the current topic is about enemy behaviors and behavior trees. However, despite following along exactly with the code in the recordings, I am getting an access violation error when I run the code. This seems to be caused by me defining APawn* PlayerPawn in BeginPlay, and immediately setting up a BlackboardComponent after it in BeginPlay, which runs while PlayerPawn is still null. Here is the code I’m working with:

void AShooterAIController::BeginPlay()
{
    Super::BeginPlay();

    if (AIBehavior != nullptr)
    {
        RunBehaviorTree(AIBehavior);

        APawn* PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);

        GetBlackboardComponent()->SetValueAsVector(TEXT("PlayerLocation"), PlayerPawn->GetActorLocation());
    }
}

And here is the exact info the error gives me, which specifically highlights the GetBlackboardComponent line when it comes up:

Exception has occurred: W32/0xC0000005
Unhandled exception at 0x00007FF9532A46DF (UnrealEditor-AIModule.dll) in UnrealEditor.exe: 0xC0000005: Access violation reading location 0x00000000000000E8.

Note: In case it’s important to see, AIBehavior is defines in the header file in the private section with the following code, nothing flashy:

UPROPERTY(EditAnywhere)
class UBehaviorTree* AIBehavior;

I have no other code beyond this for my Behavior Tree stuff so far. Is there a better way to define all of this in BeginPlay than what is done in this class’s lessons that avoids this null/access violation issue? The videos might be a little outdated for UE5 specifically (even though they say it should not be a problem).

I should mention I previously defined PlayerPawn in Tick with no issues, but I’d prefer it be in BeginPlay now so as to follow closely with the class.

It could be that PlayerPawn is null, there’s a chance this begin play runs before the main player is spawned.

That’s probably the issue, yeah. Do you have a way you suggest I ensure PlayerPawn is not null before the Blackboard code is run? I want this done as soon as possible when the game runs, and preferably not during Tick. I tried to do this during OnPossess, but it didn’t seem to work.