How to do Bomberman-like explosion

Hi,

I’m learning Unreal Engine 4 by doing an Bomberman project.

[Background]

So far i succeeded to spawn my dynamic map from a array of int.

I can move inside it, spawn bomb on the center on the tile . I made impossible to spawn 2 x bomb on the same tile. I succeeded to disable collision while the Character that spawn the bomb is still inside , then re-activate them as soon as the 2 actors doesn’t overlap anymore.

All that in C++.

But right now i’m facing a difficulty that i dont know how to handle yet. So here i am , looking for some help.

[Problem]

How could i , in c++, make my bomb explode the way real Bomberman games do. i’m quite sure i have to use particule box , but i dont know how to stop the particule at the first obstacle , making it explode if needed , all that thinking that bonus will increase the range .

Here is the bomb i migrated from the Survival Game Open Source Project, modified by me to fit better in my project.

I think the original bomberman used a tile system and just checked the tiles vertically/horizontally and affected pawns in the areas while triggering a sprite explosion there.

If you want a more analog approach then i would maybe spawn 4 of a special actor with a particle component and collision. Have the actors start at the bomb and interpolate to the max distance of the explosion. If they hit something you can choose to end or continue from there.

The particle would have an emitter that spawns an explosion but instead of standard spawn module you would use a SpawnPerUnit so it spawned nice and evenly as it travelled.

Alternatively you could just do a line trace from the bomb to see what it hits and spawn the explosion along the length with either multiple particle systems per line or by adjusting a parameter to define the area of each particle system to fill the line.

Thx ! i’ll try this out and will come back to show the result ! =)

Here is the result . I did it with line trace in C++.

Line trace is a little performance heavy and unreliable for this kind of task.

You seem to already have a index map ready for use, so I would suggest something like this:

int32 gMap[Width][Height];


void ExplodeTile(int32 TileX, int32 TileY)
{
    // Do stuff
}

bool IsTileBlocking(int32 TileX, int32 TileY)
{
      if (TileX < 0)
          return true;
      if (TileY < 0)
          return true;
      if (TileX >= Width)
          return true;
      if (TileY >= Height)
          return true;

     return (gMap[TileX][TileY] != 0); // Or something similar
}

bool HandleBombExplodeLoop(int32 TileX, int32 TileY)
{
           if (IsTileBlocking(TileX, TileY))
                return false;

           ExplodeTile(TileX, TileY);

           return true;
}

void BombExplode()
{
    static const int32 BombExplosionSize = 5;

     for (int32 X = BombX; X > BombX - BombExplosionSize; X--)
          if (!HandleBombExplodeLoop(X, BombY))
             break;

     for (int32 X = BombX+1; X < BombX + BombExplosionSize; X++)
           if (!HandleBombExplodeLoop(X, BombY))
                break;

     // Do the same for Y axis
}

And for the effects you could probably use billboards (UMaterialBillboardComponent). 1 kind for continues flames. 1 kind for ending flame.

you’re absolutely right, i dont know why i didn’t think about that. I removed the Line trace method for yours. Thx mate