How do I tell my currency to stay between levels. I’ve tried following so many different tutorials and maybe I’m just stupid but I cannot for the life of me get it to work. I’ve tried so many combinations of “set currency” and “cast to game instance” but nothing seems to work. I feel like I’m missing something within the game instance? Any help or insight is much appreciated <3
So to recap, your Currency variable lives on the character itself? If so, the character is being destroyed along with its data when the new level is loaded. You need to save this either in a save game object so it can be saved and loaded on level load or recreate the variable and events on the GameInstance itself so it can persist between level loads. Then if you haven’t already, make sure you set your project settings to use your BasicGameInstance class, otherwise it will create a generic one at runtime.
I’ve Tried putting the same code into my game instance and nothing happened I don’t know how to tell it to reference that. I have it set in my project settings yet the money still resets when the new level is loaded. I’ve also tried the same process with the Save Game Object and that also doesn’t work. I feel like I’m somehow missing the connecting link. The code is in my game instance and now also a save game object but I still can’t figure out how to reference either of them.
In your character, call GetGameInstance then cast to BasicGameInstance and pull out the resulting pin and find Currency. Use that to Get and Set Currency. Always reference the variable in the GameInstance because that and the one on the character are two separate variables.