Download

Making Random Disappearing Blocks

Hello.

I’m trying a little project that I thought up, the problem is that it is a lot harder than I had previously though.
I’m having trouble with a single thing.

There is a wall made up of 25 blocks (5 by 5), and I want the wall to have the bricks disappear at random with
a 2 second gap between each one… I can’t think of a way to do this though. I know how to remove the blocks,
and set the timer. I just don’t know of a way to assign each one a number then not have that number show up
twice.

This probably isn’t the right place to post this, but I really needed help, trying to set this up is driving me crazy.
Thank you to those that can help solve this.
Sorry for confusing people. I’m not the best at explaining stuff.


Thank you for the help.
The solution worked well, I also added a Boolean to the equation so that it would check if that number had been
called out. This did make it an unreasonably long looking piece of code, but it worked really well. The blocks
disappear every 2 seconds, and if one has already been called the it will immediately randomize the number again
and rerun the code.
If I find a way, I’ll screenshot the code at some point and add an example up here for anyone in the future to use.

How are you placing the blocks? If you are spawning them at runtime, add them to an array as they are spawned. If you are manually placing them in the level, use a Get All Actors of Class node to put them in an array. If you’ve placed the blocks as components in a blueprint, use a make array node to put them in an array. Once they are in an array, you can use the Get node, and input a random int in range node, with the min being 0, and the max being 24, and then hiding whatever it returns every 2 seconds, using a timer. Obviously this might make it try hide something that is already hidden which I presume you don’t want, so, you could also make an array of ints, 0-24, and shuffle that array, and go through each one, using the element as the index to get in your block array.

Or just use the Add Unique node, and add the result of the random int node to array each time it’s called, and only use it if it wasn’t already in the array.

Basically, an array is what you probably will want

For the random integer, have the min be zero and the max be the length on the array - 1. That way you could have as many blocks as you want.