Hello, I’m trying to make a store system.
I have total coins variable on savegame blueprint. when I’m trying to subtract the total coins the number won’t change.
(it does recognize the total coins number)
thank you!
Hello, I’m trying to make a store system.
I have total coins variable on savegame blueprint. when I’m trying to subtract the total coins the number won’t change.
(it does recognize the total coins number)
thank you!
Hey @ilailevavi! Welcome to the forums!
Everything LOOKS fine here. What about your savegame object where the variable is stored? I’ve never saved AND loaded in one continuous line like this, typically the coinage will be stored in the gameinstance or playerBP etc, then saved to file when save is called. What I’m getting at there is it might be wigging out because it’s in the same execution line.
Where are you getting the impression that the number doesn’t change? Is it in a widget? Are you looking directly at the save game? How do you know it isn’t changing, is what I’m asking.
Get back to us with some more info and lets get your store rockin!
thank you for the warm welcome.
I have coins that stored in the player blueprint. when the player dies the coins added to the total coins in the savegame.
also I have a widget that show all the coins collected. it works great.
every time I die it adds the coins that I collected to the total coins.
now I did a test in the branch. if the i have 6000 coins print string bought if not print string- not enough money. it works and recognize the coins that I have. but when I set total coins -6000 the number is stay the same.
Have you tried using your loaded game to set the player’s coin total to that much, and used the player’s coins variable to do all the math, then, when leaving the shop, set the savegame money to that amount and execute the save?
I may be completely wrong and I hope somebody shows up to tell me I am, but I am thinking it’s because there is a load and save almost directly after each other in an execution line.
I’m not sure that I understand the question. right now i have 6000 points that i received while playing. the system is working fine. the total coins is in the savegame. I tried to use delay and then save so I don’t think the problem is because there is a load and save almost directly after each other.
the coins after die that added to the total coins that stored in the savegame also load and save almost directly after each other
So let me ask this: Where is the number NOT changing for sure? Is the savegame not updating before save? Is it even saving at all? Try using a printstring after each step to make sure everything is happening. If it does go all the way through…
Maybe try making a NEW variable to save that new number to here in the widget, then setting the new value to the save game from that. ex: make new float TempMoney. Use SavedMoney, -300, set TempMoney. Set → SavedMoney.
To give it somewhat of a stepping stone, you’re temporarily saving the money float to the widget.
The thing is, the way you have it written, it SHOULD work, so I’m trying to help find a temporary workaround.
Is it possibly the widget not updating?
I have new update, I’ve tried now to print sting the number after subtract the 300 and it does change the variable! so you are right, the problem is the save. somehow the number is not saved after I’m closing the blueprint
What about your SaveGame object?
If it is indeed set correctly, try “Set Savegame” off of the return value on "LoadGame from Slot, and Set that variable so it’s specifically set to the starting values. Then, do your shopping… then on the “Target” for “Set Total Coins”, use “Savegame”.
Just a suggestion. I’m not sure that’s any different from what you have currently.
I don’t know why when I don’t see it in blueprints I can’t understand
The problem is indeed that you aren’t saving the game. You are loading up a save game object and modifying it. However, when you go to the save node, you then save a DIFFERENT save game object.
Try dragging off of the blue cast pin and plugging that into the save game node.
thank you it worked!
Wooo! Awesome!
thank you it worked!
Yay!
I ran into a different problem after fixing this one maybe you can help me with that too
after subtract the coins i want to change material of a static mesh. I tried to use set material and it works when i use it on event when the game is begin but when its on the widget it doesn’t save this change that i made. what is the correct way to change this and save it even if i open another level?
thank you !
I ran into a different problem after fixing this one maybe you can help me with that too
after subtract the coins i want to change material of a static mesh. I tried to use set material and it works when i use it on event when the game is begin but when its on the widget it doesn’t save this change that i made. what is the correct way to change this and save it even if i open another level?
thank you !
If you want to keep variables between levels, you would use a game instance instead of a save game usually.
If you also want to save the game on top of that, then you could make another variable in the save game that is of type material.
I’m not sure what all your needs are for the game, but I hope that was helpful.
I tired after subtract the coins to cast to the game instance and the make custom event that change the material and it doesn’t show up after I change the level.
when I’m using the save blueprint inside the level it works.
the difference between the game instance and the save game is that the save the data after you exit the game the in game instance doesn’t right?
the difference between the game instance and the save game is that the save the data after you exit the game the in game instance doesn’t right?
Yes. The game instance will keep the variables for as long as the game is active, but it resets if the player stops playing. A save game saves variables in an actual folder on the computer outside of the game, and the engine can access them and put them back in whenever you want.
It is not unusual for a game to use both. For long-term games like RPGs, the save game usually saves the variables out of the game instance, and then upon the player loading back into the game will then take the variables out of the save game and put them back into the game instance.
I’m not sure what your game is though. You can use these things for whatever purpose you need.