Hi , I am currently creating a clicker game , but I have a problem with saving variables here’s what i did and what doesn’t work :
I made a game instance in which i store my variables when the game is played (9 variables).
I have a user interface with a save button.
I named the variables in the save game exactly like the ones in the game instance just with an s as prefix.
Everything works fine as long as I only click and buy click “enhancements” but as soon as I buy the clicks per second upgrades (Hitlerfanatiker and Interviewer) it doesn’t save correctly (it doesn’t save anything).
Here’s how i save my variables:
clicks is an int that is incremented when you click on a button
hitlerfanatiker increases clicks by 1 every second
and interviewer increases clicks by 5 every second
hitlerfanatiker anf interviewer are the clicks per second upgrades i made a shop where you can buy those for a certain amount of clicks which is multiplied by 1.1 every time you buy one of them
when you buy them the values of the objects get incremented and the amount of clicks per second increases
Have you tried printing them out on save to see if they contain the wanted values? Also (I’m not sure if I got this correctly) when you multiply a small integer with 1.1 and save it as integer, it won’t change.
So when one of these two variables is greater than 0 and you call save and load, every variable is wrong. Perhaps the load function returns the default values? Have you checked which branch is executed? Also, does “Save Game to Slot” return true?