Bomberman type bombs

Hello unreal engineers,

I was wondering how to make that type of bomb. So for those who don’t know, basicly, you spawn a bomb in the position of the character, and after 1 or 2 seconds it explodes in 4 directions. Top, Right, Bottom, Left. If it’s a wooden box, it destroys the box. If it’s a player, it kills the player. I was wondering how to make that.

I have 2 solutions but, both seem to be veeery hard to make.

Solution #1:
Make 4 UBoxComponents and place them in 4 directions around the bomb. Override the Overlap function and do checks there whether it’s a player, box or something else. But I’m not sure it will work properly, because the functions won’t be called simultaneously (not sure if spelled right :D). In bomberman they kill and destroy everything simultaneously.

Solution #2:
Perform ray traces in each direction and do checks. But I think I’ll have to make thousands of checks and actually perform more than 4 traces. Because if it hits something. It needs to continue even further. to check if there is a second player. Plus, I’m not sure how to limit the length of the trace.

So guys, any help is appreciated. Tell me which solution would be better. And if you know a third one, please share it :slight_smile:

You could use a “Multi Line trace by channel” node. It will trace through everything and ignore whatever you put into the “Actors to ignore” array. You cast the hit actor to the box blueprint i’m assuming you have created and call the Explode event you made. here’s the documentation for Raycasts :

Yes but, what happens in this case:
A ray trace is performed in right direction, and hits the first player. But the line continues forward and there is second player, how do I hit him again? I need to perform second, and what if there’s a third one?

Because when a line hits something, it stops and returns a hit result

I guess when it hits something, it has to do checks, and then continue while it hits something else.

Single line traces will only return the first blocking object. This wont give you the piercing effect you want.
Multi line traces will return an array of objects it passed through, this will probably be what you want.

Alternatively you can make something similar to a shrapnel bomb(but with only 1 shrapnel in each direction). To do this you make an Actor that acts as a projectile, which over-lapses pawn and is blocked by statics. Then add an event to do something on overlap. Its a bit silly but there is no reason for it not to work.

Maybe I’m getting you wrong, but as I understand your problem it’s fairly simple:
As far as I know Bomberman is played on a 2D chess-like playing field, so there is a fixed set of tiles identified by there x and y position. Those are most likely stored in some kind of 2D-Array, therefore it shouldn’t be a problem to get the position of the bomb and when it’s exploding iterate in all four directions over the array and check what was hit.

@Siveon - Oh actually that solves the problem. If I check the distance between the bomb and the hit.Actor (based on the length of the explosion) then I can easily do required stuff (kill player, destroy block etc)

@Taces - Yes I know it’s 2D and probably stored in an array, but I wanted to make 3D version. Plus I think that would make things a lot harder if in array. Especially iterating.

Don’t think of it as one bomb. Think of it as the “visual” part… (the bomb) and the “bomb” part (damaging actors). Spawn the visual bomb, but also spawn triggers either side of it at the correct distances. The triggers are simply that, collision volumes that report what is inside them. They should have the same timer as the bomb. When the timer expires, the trigger checks what they currently overlap and damage anything inside them. So basically you’d see a bomb plus a bunch of collision volumes in the editor (triggers are invisible to the player after all).

For added effect, you can also spawn a particle effect within the trigger.

For added added effect, you can delay the trigger a bit scaled by the distance from the bomb position, so you get a nice explosion ripple effect.

Well this is a great example of how a thing can be done in many ways. I will try both and see which one is better or easier to do. Thanks everyone.