Hello,
I’m a beginner in UE5 and I’ve been trying to create a small, simple project where the player have to collect some items and after he gets everything, the wall covering the finish line will disappear / be destroyed and player would be able to reach the finish line.
I already created “Coin” actor and the counter in the upper-right corner. After player gets in collision with coin, it will dissapear and the counter will be increased by 1. The problem is, I can’t make the wall disappear after collecting a certain amount of coins.
My idea is to create that “Wall” as an separate actor and then, in “Coin” actor, check if the amount of collected coins is equal to a certain number (for example: 1). If yes, refer somehow to the “Wall_Actor” (i thought of using “Cast to Wall_Actor” but I’m not sure if it’s correct) and then “Destroy_Actor” to remove that wall.
I also set up a “Print String” at the end to see if i’ll get a message after collecting 1 coin, but there’s no message. I have no idea what’s wrong here and I’ll really appreciate for any help.
There will be many ways of doing it - depending on how things are set up. The below assumes there is only 1 Wall and it is in the level already, and so are the Coins.
make the wall disappear after collecting a certain amount of coins
Whenever a coin gets Destroyed, the Wall adds 1 to the counter. When we hit the threshold of 5, the wall destroys itself. Would that work for you? Do tell as there are more ways, some better than others.
One note:
Avoid calling stuff after Destroy (self), chances are this actor is gone and there is no absolute guarantee the following nodes will be called correctly.
Thank you very much for help, it worked. I haven’t mentioned it earlier, but indeed there was only one wall and it was already placed on my map, as well as all coins.
However, I still have a question (simply out of curiosity). You said that there’s many ways of doing it, so is to possible to do it in the way I described earlier?
I mean, to destroy that wall using only “Coin” actor by refering somehow to that particular wall and without puting anything in “Wall” actor Event Graph?
The thing is that doing anything inside the coin actor would not work well - coins cannot do much or count as they’re getting destroyed. The player could count the coins, ofc.
Consider the following:
the player has coin destroying and counting script and can reference a wall actor: