Destroy a wall after collecting some items.

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.

My “Coin” event graph blueprint looks like that:

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

  • in the wall actor:

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:

image

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.

2 Likes

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:

  • if I place the player in the level directly, I can reference any wall (yellow cubes) I want:

Here, there is no script in the wall or coin whatsoever.

1 Like

Don’t forget that every level sports a blueprint graph as well:

It can directly reference anything inside this level. Now you need no script in any of the actors.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.