using Game instance without cast to

hi.
in my game instance i have a variable “health”.

i want get this variable in my BP_Actor without using cast to, how i can using it with blueprint interface ?

Hey @david1021542!

You will probably want to move that over to “GameState” instead of GameInstance, as GameInstance is reset when the game is closed, so the value wouldn’t persist.

Also don’t worry about casting! There’s no reason to avoid hard references if those objects are already going to be loaded in memory, which means the GameInstance and GameState are not a bad idea to cast!

Regardless, you’ll use “GetGameInstance” → Get: Health (or whatever you named it)
OR (my suggestion) Switch it to the GameState and use “GetGameState” → Get: Health! :slight_smile:

3 Likes

i find how to get my variables from my game instance without using any cast, i share my solution here



This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.