Save Objects

Have asked before but still cannot figure it out…

GOAL: Pick up a coin, the coin is destroyed. Exit Game or level and reopen and the coin is still gone?

So apparently I need to use array variable, save the game object and a for each loop. Thats all I know.
How do I do it? Thanks

Hello I did find a cool Unreal Engine video that might help. It is from the Endless Runner Tutorial series. From the Unreal Engine YouTube Channel.
Good luck!

I watched this also but no closer. Unreal Concepts - Persistent or Saveable Objects ( UE4 ) - YouTube

The answer is the same as before :wink:

You need to use a save game:

Basically, as the player picks up coins, you record in the save game which ones were destroyed. Next time they run the level, you load the save game and destroy the coins for them as the level starts.

EDIT: I’m assuming the coins are BPs, so you can give each one an ID ( integer ). All you have to do is put the ID of the destroyed coins in an array in the save game. Next time you load, read all the IDs from the save game and re-destroy the coins.

Did you place the coins by hand? Are there many? ( like hundreds or twenty or so ).

And are the coins a BP or just a static mesh?

Yes placed in by hand. There are about 15 - 30 per level. 150 all up. Nah there a Blueprint.

Your a legend brother, sorry just can’t wrap head around this. How do you give each one and ID? And how to save it to array?

Ok, so if the coins are BPs, then make a variable in the BP, called ID. Make it an integer and switch the ‘eye’ on, so you can see it in the viewport.

Then you just have to go through the level and give each one a different ID. Start at 0 and keep going. Keep on using higher numbers, even when you do different levels. Don’t start at zero again.

Concept is this: when the player picks up a coin, before you destroy it you put the ID in the save game.

Next time you run the level, level BP reads the save game and takes a look at which coins you picked up last time and just destroys them on begin play.

EDIT: I’m going to show you the code, gimme a bit of time…

Make a save game object, call it MySaveGame.

In the save game, make an array of int, call it UsedCoins.

You need this in the first level BP, only the first one:

In the coin BP you have this:

That’s it :slight_smile:


Excellent :slight_smile: