Adding and removing actors from an Array?

I’m relatively new to using UE4 and I’m trying to recreate a puzzle game I started making years ago on an old, outdated program. I have, after much trial and error, managed to get most of my core ideas down and sorted, what I am struggling with, however, is arrays.

What I have here, is when the player passes over the striped blocks, they explode. What I need is a way to check to see if all the blocks have been destroyed before allowing the player to move to the next level (and change a red light to green). As I understand it, the best way to do this is with an array, but after reading lots of articles and tutorial videos, I STILL have no idea how to do it. Can anyone offer any advice?

Much appreciated.

There are many ways to approach it. And arrays help but are not technically necessary here.

Consider the following:

  • at Begin Play we count the blocks and store the amount
  • when the player runs into a block, it gets destroyed and we count down
  • when the Block Count is low enough, the game is over

Image from Gyazo

1 Like

Ok… I see what it’s doing, but I’m having issues.

Walking atop the boxes, as I need to happen, the “On Component Hit” doesn’t do anything. I tried it with “On Component Overlap” but its very laggy and only seems to affect every other box, not destroying around half of the objects.

I also can’t figure out what that “SET” node, or the “–” node are… I can’t find them.

Walking atop the boxes, as I need to
happen, the “On Component Hit” doesn’t
do anything.

I was under the impression you already had destroying mechanics in play since the stripped boxes were exploding - I’m not suggesting a new method; use what you’ve got. I was merely suggesting a way to count.

The Set node is just a Set node - it’s an integer variable, it keeps the track of the number of boxes left. You can get / set variables:

Which is equivalent to reading / writing data.


Were I to suggest an interaction method for destroying actors we stepped on, I’d probably opt for attaching a smallish sphere collision to where player’s feet are and use on END Overlap:

Image from Gyazo

1 Like

I had already had destroying mechanics, but I had to modify them to incorporate your incredibly helpful guidance, and after a little bit of fiddling about, I’ve gotten it to work, thank you so much for your help, it really is greatly appreciated.

Ah, cool - glad to hear that. Good luck with the rest!