Andy_rst
(Andy_rst)
1
I try to get local player but always get null pointer:
void AMyBasePlayerController::GetPersistentUser()
{
ULocalPlayer* localPlayer = GetWorld()->GetFirstLocalPlayerFromController();
UMyLocalPlayer* RoPlayer = Cast<UMyLocalPlayer>(localPlayer);
}
RoPlayer always is null!
TheJamsh
(Jambax)
2
The reason would be that the cast fails, so you’re not using your custom Local Player class.
Go to Project Settings -> Engine (General Settings) -> Local Player Class and switch it to your custom class. From then on it should work.