0
Answered

Saving Local Variables

CJWorkshop 2 months ago in Game Creator updated 2 weeks ago 3

Hey, 

Is it possible to save local variables as soon as they change? I have tried clicking the tick box so that they do save, but it seems i have to activate the save game action for the local variable to be saved and stored. The issue is that using the save game action, also saves the position of my character, which is something i don't want to happen.


I'm making a platforming game and want collectibles to stay collected after the game has been loaded (Having to collect each one again after a checkpoint is a bit annoying in games) I have worked out how to do it with global variables, but i read having loads of global ones isn't the best thing for performance and i plan to have 1000's of things to collect, around 100 in each level. 

Any help with this would be greatly appreciated, it is something i'm a bit worried. 

Unity version:
Game Creator version:

Answer

Answer
Answered

You can "disable" saving the player's position and rotation by selecting the Player object and, under the Advanced Properties section, uncheck "Save" checkbox.

Regardless, if you want to save the game every time a variable changes, you can use a Trigger "On Variable Change" and use the "Save Game" Action.

Answer
Answered

You can "disable" saving the player's position and rotation by selecting the Player object and, under the Advanced Properties section, uncheck "Save" checkbox.

Regardless, if you want to save the game every time a variable changes, you can use a Trigger "On Variable Change" and use the "Save Game" Action.

Is it not possible to alternate between saving the players position and saving global variables? I want to save the players position when he is at a checkpoint, but i also want to save only global variables and not the players position when the player picks up a collectible. 

Thanks, that has helped a bit, but now I've encountered another problem.

I have local variables numbers tied to each of my collectible items. These local variables have been ticked, so that they save between scenes. When i collect an item it's local variable number gets set to 1. I then have two triggers, on start and on load which determine if the variable is on number 1, if they are, it is meant to destroy the object, but this does not happen when i reload the scene even though the variable number is still saved as 1.

The odd thing is though, if i manually set the collectibles variable to 1, that object will be destroyed on start and on load. Any help with this would be greatly appreciated, i just don't understand what is going wrong.