[C++] Script cant acess playerClass ?

I want a reference to my playerclass for my hud. But the player reference keeps to be null.


 world = GetWorld();//getting the world
     if (world){ con = Cast<APlayerController>(world->GetFirstPlayerController());//getting the controller
                   UE_LOG(LogTemp, Warning,TEXT("WORLD")); }//This works fine
     if (con){ player = Cast<APlayerCharacter>(con->GetCharacter());//planing to get the playerclass  
                 UE_LOG(LogTemp, Warning, TEXT("CON")); }//this works fine too
     if (player){ UE_LOG(LogTemp, Warning, TEXT("Player")); }//but this didnt got called...why ?
 

Depending on your template or GameMode your player class may not be APlayerCharacter. Try casting to APawn.

It may also fail because no player has spawned. Can you confirm that con->GetCharacter() is not null?

i dont get it o.O yesterday it didnt worked. And today it works o.O. I did not change a thing