191880-
Hi Guys, i have a problem when i try to cast to PlayerState from Game Instance, i have try with
inside on my custom function but always return Null pointer.
Can anyone help me?
Thanks, Andrew
191880-
Hi Guys, i have a problem when i try to cast to PlayerState from Game Instance, i have try with
inside on my custom function but always return Null pointer.
Can anyone help me?
Thanks, Andrew
ahh so i can cast only from AActor type class to derived class of this,right?
there aren’t any solution for cast from UObject to AActor, correct?
So if i need to access PlayerState from GameInstance exist any type of solution or i need to change my “concept” game logic?
Thanks for Advices,
Andrew
Casting has be done on a pointer of the derived type. Example below is if it were done inside a APlayerController.
AMyPlayerState* MyCustomPlayerStat = Cast<AMyPlayerState>(GetPawn()->PlayerState);
Your function will always return NULL because you’re trying to cast a UClass pointer to AMyPlayerState.
AMyPlayerState* PlayerState = Cast(GetPrimaryPlayerController()->PlayerState);
This will work in the GameInstance.
Thanks man for the info, this gave me the right direction!