Announcement

Collapse
No announcement yet.

[C++] Script cant acess playerClass ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [C++] Script cant acess playerClass ?

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


    Code:
     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 ?

    #2
    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?

    Comment


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

      Comment

      Working...
      X