Download

Array of actrors

Hi!
I have already asked this question, but I have not received an exact answer.
I’m studying at UE4, creating an arkanoid. I encountered the following problem:

There is a schema that I use to create a set of blocks (From_blocks) of a single actor (From_deconstructable_black), and I want to get a “Win!” message when destroying the last block from all the created blocks
How can I do it?

If not difficult, describe in detail how

There would be a number of ways to do this.

One easy way would be to basically have a counter variable which you set to the amount of blocks in your level when the level starts. Every time you destroy one, deduct 1 from this counter and check to see if the counter variable <= 0. If it is it means they have all be destroyed and you can do what you need to do, if not, then do nothing.

A good idea, but how do I implement it correctly in my blueprint logic? I have a separate blueprint that creates spawn blocks, and another blueprint destroys the block. In which of them to make a counter and how to link them in General in this case?

I can only assume that when you spawn the blocks, you have something to determine how many you are spawning. If so, when you’ve spawned the blocks, set the variable to = the amount of blocks you have spawned

Everytime a block is destroyed, deduct 1 and do a check to see if the variable now = 0. If so, you Win the game.

Depending on how your BP’s communicate, you could always store the variable inside your game instance, that way you can access it from anywhere.

You can use EVENTS… Spawn a block … call a block to increment count. Destroy a block call an event to deduct from count.

The events can be in the Level Blueprint, Game mode etc.