Hello, I want to “cast” variables from my GameInstance to my PlayerState so that I can modify them and show them with a Widget.
The stupid question is how can I refer a variable from the GameInstance class to the PlayerState class? It is a simple procedure for BP but I can’t find a way for C++.
Thank you in advance!
Can you show how you do it in Blueprint? Just to make it clear
This is a similar screenshot. The difference is that the class I “cast” the matrix (General Key Assignment) is not the PlayerState but the PlayerController class. In BP programming I put the “cast to” GameInstance block and call the variable (tthe matrix in this case) inside the event graph of the PlayerController class. I tried to do this using C++ but I think that UE4 C++ syntax is different.
Not sure I’ve understood what you mean but to make something like that you could simply do:
UGameInstance* GameInstance = GetGameInstance();
MyGameInstanceType* MyGameInstance = Cast<MyGameInstanceType>(GameInstance);
//if (MyGameInstance == nullptr) return; always check...
MyGameInstance->GeneralKeyAssignment[0]...