Hi guys, I want my game to load settings just once and for all ONLY when the player launch the game. Therefore DO ONCE functions are not working in this case… How do I do that?
Add a bool “Are Setting Loaded” into the Game Instance and change to True it after the settings are loaded. If the bool is True, don’t load settings.
I didn’t do this, as I only use SaveGame and GameInstance stuff, instead of “Are Setting Loaded”, but I’ll still try this
Like Tuerer said, except you need to store it in the save game, to make sure it never runs again.
I did something and it works fine ! No need to call SaveGames actually, I just put at the beginning of my game a cast to my game instance and I get the ONCE_Enabled. Then, as my gameinstance isn’t load yet, the return value of that variable is false (its default value). If it’s false, it executes a load, and at the end it put ONCE_Enabled on true. And if it’s true, it executes nothing. In fact, all is working thanks to the default value of my variable Thanks !
If you quit the game and restart, it will run again…
Yes, but just one time. Oh I see you thought it was once time for all in your life, yeah I was not precise enough.
This is a function the GAME MODE class should take care of.
Either if your game is single player or multiplayer.
In game mode you have a lot of functions to overwrite, including on player pawn spawned. And it triggers once - allowing you to run logic with authority on the pawn or controller directly. in example - fill inventory from savegame.
In my case worked , if I duplicate a level and create a variable level name, where it works as once setting that overrides the variable on the level name to LevelName*Duplicate without setting … and then it always loads the second level, which is the same, just without the once function.