Hi everyone!
So I was trying to make a coin system; when the player picks the actor( A.K.A the coins) I want them to be destroyed and not appear again even if you reset the level in-game.
I tried to make it with a Game Instance and Boolean but, surprise to me, when I just pick one actor and go to another level, all of the same actors are destroyed too!!
Can someone help me? (Sorry if it’s confusing, I don’t speak English very well)
If you want to only destroy the current instance of the coin, then what you have in the bottom half is fine, you don’t need the top half.
Also, you only have one boolean in the game instance. If you wanted to have a boolean for each coin, you would need to have an array of booleans, one for each coin. The game instance is global, it’s not local to the coin.
You can assign ID to every coin, and create something like “map” variable with int-bool config. And when you collect coin, set bool to true where int = ID. Then on begin play get coin ID and check map if bool = true.
So, ID is custom variable - go in your “Coin” actor and create variable “ID”. Then you’ll have to set ID on every coin you have on your map. Then, somewhere in gameinstance create variable and set type of it to “map”. It’s in variable details, to the right of name (default is strange circle), click on it, and at the end set to map(first set type of variable to int), and set second type to “bool”. Then, with node “Find”, find bool by coin ID, and if bool true, then destroy actor. AFAIK when you “add” and set “key”, value of this key-value will change, and will not add.
I think your solution it’s the best but I don’t know how to make it. I never heard about IDs…And I don’t know how to create a variable with “int-bool configuration”. Can you help me a little more?
Okay I’m a little lost… I was able to create the Game Instance variable map. And for the ID variable, I had to create a variable call PlayerState and then I could find the ID there (I tried to fine variable “ID” but there wasn’t anything like that ) And with the “Find” node, I’m also a lost.
I know this probably it’s something easy and sorry D:
With map seems you done everything correctly. Find node, you have to drag pin from map and get “find” node for map. ID is not pre-created, it’s your variable that you have to create in “Coin” actor(like how you created a map, only integer). This ID you have to pass to find node.
Now my blueprint is like this… I made the Integer variable and assign every coin of my map their “ID number” .
But now when I “collect them” and then re-open the same level in-game, the Coins are still there. I know I’m missing something but I don’t know what is it.
Well, it hard to tell right now - it might be that on collision start(where i suppose coin is “picking up”), there is no “add” node to map. Drag add node from map, and pass to integer value your coin ID, and to bool, set true. It also can be that in “find” node you’re picking wrong bool. There’s two of them and I’m not sure what bool correspond to what.
(Not be afraid to be annoying when you’re willing to learn)
It worked! Thank you so much for your help, and yeah I learn new things with this! I didn’t have any idea about IDs and Variables “map”, so really, thank you so much!!