And when I restart a level, then it wouldn’t appear?
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.https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/
Destroy the coin actor if you don’t want it to appear on the map anymore.
Well, there’s a lot of ways to do this. But if you simply just destroy an actor, on level restart, it will typically appear again (depends on how you are doing it). But, what’s easier to do, is just have a bool. bCollected. When picked up, have this particular referenced actor set bCollected. Then on Level Load, check to see if any actor has been collected already or not. The thing about this is… simple Open Level or Restart Game, will reset all these values. So, you will need somewhere persistent to keep track of this. Either a SAVEGAME or Game Instance is your choice. This requires you to have references for each of these actors however.
Sounds exactly what we’ve been talking about… /shrug
But how to use it? These videos don’t really tell anything useful for me.
Let’s say we have 60 coins on the map. When we collect them, they will be added to our sum of coins, but they won’t appear on the map anymore.
Even after restarting the level?
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
Wow. That was easier than I thought. Thank You!
I may have misunderstood the question then
Thank you anyway.