I will explain in depth the reason for which I need to do this:
I have a game, which randomly generates a grid of blocks, using 1 actor. The actor makes a bunch of instances of itself for performance reasons.
My grid of blocks also includes places where blocks aren’t at, but could be if you wanted to place one down. Here’s a picture example:
As you can see, I have air/empty blocks, and dirt blocks. The empty blocks are included in the arrays because you can place blocks their, so arrays reserve a space for them.
Now here is where the problem comes in:
I have it so that you can destroy blocks by clicking on them. What I do is I do a line trace to the block, subtrace some HP, check to see if HP < 0, and remove the instance. To know which instance to remove, I drag the ‘hit item’ return node from break hit result to the remove instance. The problem is that I know which item I clicked on, but don’t know which index I need to subtract HP from, because air blocks are skipped, and aren’t counted as instances/‘items’. Here is another picture to help you visualize.
So as you can see, the index of the item is different than the index I would need in the HP array. What happens is that if I tried too damage block 3 for example, it would destroy it immediately(rather than 3 hits/clicks) because my empty blocks have 0 HP.
Can anyone help me? I need to find out a way to get the proper array index from the ‘hit item’
I was thinking that maybe there is a way to spawn some ‘blank instances’ inside the empty blocks, that way the item index would match up with the arrays indexes. Can I do this?