Save Coins to Character

Hello guys i’ve been trying to make a Endless runner but i got stuck when i try to save the coins for my game i get them saved but i get added coins everytime they spawn in my world i got a sphere collision for my coins but it still adds them when they spawn and when i collide with them. Sorry if its a beginner question but i tried everything and cant seem to find an answer online. down there two photos of my create/load save game and my save system for the coins when they get picked up

Are you saving each time that you got the coins ? This will create burden.
If you want to use coins, this can be an architecture for you.

Save game data can be under Game Instance, can use save and load from there.
Playerstate or PlayerCharacter, can fetch the coins from the “save game data”.
During gameplay manipulate things in playerstate, add coin, remove coin, spend coin.
So when you complete game, or destruction of your level, you can trigger savegame function from player state, or player controller whereever you want.

I hope this will get close to what you want to achieve.

1 Like

I will try to find a tutorial on Game Instance and see if I get a fix . Thanks for the tipp I will do this after work and i will return with an answer .

You’re saving the score correct ( it look like ), but the coins also need to know they should not be in the level next time.

If you give the coins an ID ( just an int ), they can store if they have been picked up in the save game. Next time you run the level, the coins look in the SG. If they see they have been picked up, then they just destroy themselves.

1 Like

So just like give the coins an int called ID and do i need to write a code so they know what to do ? Sorry for the dumb question but i just started coding like 2 weeks ago and i do it after work, tring to learn.

Yes, the coins have to say ‘I’ve been picked up’ to the save game.

In the coin


When you put the coins in the level, each one has a different ID.

1 Like

Thank you guys for the support i finally managed to fix it didn’t use the id, it seems i was casting it wrong the whole time because i have already had a collision effect for my coins just had to add the code for adding coins to save game to that and it works now .