I think there’s a few things to sort out first.
Firstly, In Bomberman, bombs are locked to a grid. No matter when you place it, it will always align neatly with the level grid so that when it explodes, each of the 4 directions will expand outwards to their maximum cleanly along the level. So are you having the explosions locked to a grid? If so, it makes it a lot easier.
What I would do (and I am by no means a professional so this may not be the correct way) is use a Line Trace By Channel to do a trace outwards from the exploding bomb in each of the 4 directions. You can also pass in the explosion size into the line trace so it will only go as far as the explosion will, saving a headache later (If you’re saving it like “Bomb size = 1” to mean the explosion will extend outwards one grid space in all directions, multiply that value by the size of your grid). Then, for each of the traces, check to see if it hit something.
If it hit a non-destructible wall, get the length of the trace, divide by the grid size then round down to get the number of grid spaces the explosion should affect.
If it hit a destructible object (wall, player, whatever), do the same thing but add one more grid space to the result (because you’d want the explosion to encompass the object). Then, probably use an interface call on the hit object to say “I exploded you. Do what you gotta do”.
If it didn’t hit anything, simply use the bomb explosion size as the number of grid spaces to encompass.
Finally, you’ll need a visual effect to accompany this. You could create a particle effect to represent the explosion and spawn it for every grid space that is encompassed. To obtain the location of those spaces, simply use the bomb’s location and add an offset equal to the number of encompassed grid spaces (found above) multiplied by the size of the grid. So if you found it should encompass 5 spaces, you could run a loop 5 times. For each one, add one to the loop index, multiply it by the grid size and add it to the bomb explosion location in the appropriate axis.
You could also potentially come up with a single particle effect that could span the entire width of the explosion, so even though it encompasses 5 grid spaces you would only need one effect.
I guess you don’t need a particle effect at all, a 2d flipbook would work too if you were doing it that way. I guess I have no idea about the style you’re looking to achieve.
I read through the link you posted again and I see they first suggested a line trace as well but decided against it in favor of the index map. In the first image posted (
) it looks like the game map is indexed into 0’s, 1’s and 2’s with 0 being floor, 1 being a wall and 2 being a player. Whenever a player moves, the index map is updated to represent their current position on the map. So when a bomb explodes, you only need to check the map to see what is where in order to determine what needs to go boom. You could accomplish this with blueprints although I don’t know what the performance tradeoff is instead of a line trace.In order to do this with blueprints … hmm. I imagine your level blueprint would need to handle the index map. So you could create an int array there to represent the level. You could create an actor to look to the map and build the level in a construction script so you can see it in real time. Or just have the level blueprint create the level when it starts. Then you would need something to monitor the movements of the players. I guess in the event tick of the level blueprint, you could check the location of each player, divide the X and Y to get the index into the array and update it appropriately. Bombs would also need to be added to the map too since explosions collide with other bombs (I believe in Bomberman if an explosion hits a bomb, it explodes as well). Is that more performance intensive than a line trace? Don’t know. It certainly seems to overcomplicate things.
So if you were to create a map for this, you would probably pass all the work off to the level blueprint. When a bomb blows up, call an event in the level blueprint to say “Bomb at X,Y exploded”. In the level blueprint, you would need 4 loops, same as what is seen in the “BombExplode” code. For each axis, start at the origin of the explosion and loop for the size of the explosion, checking to see if it’s a 0, 1, or 2. Or 3, if that is used to mean a bomb. If it is … uhh. Hm. In the C++ code, they just say “Explode the tile at X,Y”. But that doesn’t help much. You would need to get the actor filling the space at X,Y. I think the cleanest way to do this might be to use an array of actor references rather than ints. (EDIT: Actually, it might help to have two arrays. One with the map index containing ints which will be used for the initial build of the level. When the level is built, the actor references can then be placed into a second array with the same size. Because if you had ONLY actor references, there would be nothing to reference when it starts. You can’t reference nothing and build a level out of it. ORRR you could make your own structure containing an int and an actor reference then have the map be an array of that structure. You would need to manually initialize the array with ints and all of the actor references would be null until the game actually populates the map). You can simply contain more information there and don’t need to worry about trying to find an actor once it is triggered.
Ok so a lot of this was maybe rambling a bit but it was kind of a vague question so the answer is a little vague too. But I hope it gave you some ideas and feel free to ask for more details about stuff.