Bomberman-like Gameplay; Bomb Functionality

I’ve been working on a bomberman-like game and I’ve made an actor which automatically generates a grid system based on the numbers I enter. Results looking something like this(the transparent stuff are empty grids; no collision);

And I’m using a simple random bool to randomly fill it with obstacles, obviously this is just for quick testing purposes - but it yields results such as this;

These have collision and will be destructible. But the issue I’m currently having is trying to figure out how to do the logic for the bomb. I’ve been trying to have the game detect if I left-click while inside one of those empty grids - but I can’t seem to find a way to do it. Since I don’t have collision, I can’t really use overlap events.

I tried to use component tags and I managed to give them their own ID. But that’s about as far as I got, I couldn’t think of a way to make use of the component tags.

So I’m at a dead end at the moment. Not only do I need to figure out a way to detect when a bomb is planted - but I also need to achieve similar behavior.

One way I know I could do it is to use raycasting, but that seems rather inefficient and I’m sure there’s a better way to accomplish this - I just can’t seem to think of one.

Is there ever a time you cannot lay a bomb? If I remember bomberman correctly there wasn’t an area I could get to where I couldn’t lay a bomb. There was just a small delay after laying one.

The most efficient way to do this would be to also spawn collision on every empty tile, so you can set a bool (bCanLayBomb) to true while inside of them.

Not that I have planned, for now there will just be a cooldown.

The problem, though, is that the StaticMesh I use can’t have collision as I can’t specify as to what will collide with it or not - so then I’d just be stuck inside or on top of the objects.

I made this real fast to try and demonstrate what I’m trying to do. Imagine each of these grids consist of the blocks I have, and this is the legend;

White: Empty, not visible to the player(can be made visible for debugging)
Gray: Indestructible blocks, to prevent the players from escaping the level
Brown: Destructible blocks, if a bomb can reach this block - it will be destroyed
Blue: Blocks randomly assigned to work as spawn points for the players
Red: Bomb
Yellow: The neighboring blocks that need to be checked whether an explosion can occur there or not

Basically, I’m not quite sure how I should achieve this since I am using an actor that generated a grid system with static meshes.

I tried making each block a separate blueprint, but that meant I had to use Add Actor as Child Component so that means I can’t cast to them to change the variables and such(unless I’m doing something very wrong?).

I might simply have to remake the grid generator, I’m just a bit stuck on how to go about achieving this while also having it fairly customizable in terms of size and such.

Edit:

I completely forgot about the collisions I can add as a component in the actor BP itself, rather than on the StaticMesh. And in doing such I have full control over what collides with it and not.

So I’m currently in the process of building an entirely new grid generator. But if anyone has any suggestions or advice in general I’d appreciate it!

The collision would be set to OverlapOnly so it won’t stop your characters or bombs for that matter from passing through. Are you saving every grid tile into an array? If so you should be able to reference them based on the tile the bomb is placed onto.

For instance for your example above, say the bomb is on tile 55. The left area would be 55-1 the right area 55+1 the top area 55-14 the bottom tile 55+14. This is assuming the grid tiles are placed into the array in the order of top to bottom left to right.

Aye, I stumbled upon that so I just rewrote the grid generator to use actors instead. So now I have a separate actor BP for each grid(Empty, Destructible and Indestructible).

I can use the overlap event for the empty grids, which is great. However, there’s still an issue - since it’s added as a child actor component - I can’t access variables of that actor - nor can I cast to it.

So basically, I can’t do anything with the actors I’ve added.

I’m assuming I would have to do this in the Event Graph rather than Construction so I can use Spawn Actor from Class - but I want the ability to be able to change the grid size on the fly in the editor.

Edit:

I may or may not have found a solution to the problem. I use the Construction Script to build a reference that shows up one-the-fly in the editor.

I then use the Begin Play event to loop through all added grids and get their world location and store them in a vector3 array(one array per type).

I then destroy all the added grids since they’re child actors and basically useless to me. Then I loop through the vector locations and use Spawn Actor form Class instead.

This way I can manipulate them as I want. Will report back with results in a while. :slight_smile:

Then the event graph is what you want. You could even re-randomize it from within the game with the below script:

Full Res: http://i.imgur.com/QX7uE3v.jpg

Ugh, sorry - I was fairly sure I had replied. There seem to be some cache issues going on with this website. :frowning:

The method I mentioned above worked exactly like I wanted it. There’s still some logic to work on when it comes to grids - but I can now get a grid by specifying a certain ID.

Here’s a little test video if you’re interested;
https://streamable.com/uztt

Looks awesome! Keep it up!