Is there a way to make a coin save that it had been collected?
And when I restart a level, then it wouldn't appear?
asked Jul 31 '17 at 11:58 PM in Blueprint Scripting
Yes there is. You can use Game Instance. Part of the Game Framework. Game Instance is persistent throughout the game. Increment a variable there and get it at anytime when you need it. If you don't want to use GI, you can use Save Game.
answered Aug 01 '17 at 04:04 AM
Create a Blueprint Class extended from GameInstance. There add a variable to your collected coins (GameInstance remains even if you change levels) On the actor that fires the event when the coin is grabbed (probably your character), add a GetGameInstance and cast it to your custom GameInstance to access the variable you just created and set it to its current value plus one.
Every time you need to access that variable you will need to cast to your GameInstance class, if the casting has to be done many times, then you might want to do the casting in the BeginPlay event and store the GameInstance reference to use later.
If you want the value to remain after exiting the game, it has to be done with the SaveGame class, explained here is the setup of how to save and load a variable with the SaveGame class > https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/index.html
answered Aug 03 '17 at 08:37 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here