this is my code of a blueprint class (actor) that I created. so what was suppose to happen is that I place lots of this class (a coin) on the map. And when the player touches it/goes on it it would add 1 to the score variable, print it, and destroy itself. It kind of worked. I placed some and the player can collet it, and it would print score. But the problem is that the score would not add. The first time it prints “1” , then it would always be “1”, even when I enabled “instance editable”. What is this weird problem and how do I fix it?
You should probably cast to another actor and set this variable. Once you destroy the actor it’s information is destroyed as well. So for instance your character is running into this actor you should cast to this character and set it there. Otherwise it’s lost once it’s set and destroyed.
P.s. you also want to make the variable instance editable also to set it outside of itself.
is this how I do it? This is my code but it still does not work, in fact, It got even worse. Now when I touch it it does not get destroyed, and it just keeps on adding 1 to the score every time I come close. How do I fix it???
Probably something like this:
Edit: The cast is most likely failing on your previous post. You’ll need to create that score variable in the other blueprint such as your character or pawn and make it instance editable. In your coin BP you can access that variable from the cast and set it like in my screenshot. This should work for you.
thank you so much you solved my problem! I would have marked your answer the correct answer but I don’t know how.
Not sure, but I believe there is a selection on the reply that says solution or something, but no worries glad to help