Apply Damage to all Attached Children


I got a bullet type which on impact spawns a box and destroys itself.
This box can then have damage applied to it. When that happens it’s collision is turned off and it’s physics are turned on while a cool decompose animation plays and makes it look like the box vanishes into thin air.

Here is the thing though: When you fire a box to another box they attach to each other. But if you make a long line of these boxes and then shoot one of the boxes further up the chain so that many boxes would fall off, only the box you shoot decomposes. The rest of the attached boxes sort of flips out a bit then disappears and reappears at the bottom of the level, still attached to each other. I’ve tried to make it work so that if I shoot one box with attached boxes, all of the boxes will lose collision, turn on physics and decompose into nothingness before disappearing. This have proven to be a challenge.

So how I tried to approach it is as such:

  1. Shoot a Box
  2. If the box hits another box already spawned, save a reference to that box and pass it on to the newly created box’s constructor.
  3. The newly created box then takes this box reference and pass it on to an array that the box it hit has. All the boxes got an array like this in case they are hit with multiple boxes.
  4. When a box is hit, I enable physics, place a 0.5 seconds delay, then apply damage to the box, making it trigger the “Take Any Damage” event and then decompose into nothingness.
  5. After I apply the damage, I run a For Each Loop on the array of boxes that might have hit it and apply damage to those as well. This should make them decompose too.

But instead all the boxes that are attached to each other, just falls to the ground, spas out and then reappears at the bottom of the level in my KillZ Volume.

Here you see the boxes attached to each other, by me simply shooting them out:

As you see here the box at the very end where I shot it off is almost completely decomposed, yet the other boxes don’t change at all:

Here is the On Hit event for the bullet that spawns the block:


And here is what happens when the block is constructed:

Then when the box is hit:

The Take Any Damage Event:

So really, any help would be appreciated!

Bumping it up

Bumping it up