Download

How would you design a grid- or tile-based map system in UE4?

I want to create a tile-based map system like in those old (isometric) 2D games, like a grid of tiles. The terrain itself does not necessarily need to be made of tiles, it may be one mesh, however, visually it should look like as if made of tiles. In any case I would like to add a grid overlay to indicate these tiles, to do things like highlighting tiles when selecting them with the mouse (e.g. in a map editor) etc.

First I tried it with single mesh actors for each tile, but that leads to very poor performance with large maps (10.000+ tiles / grid cells). Then I tried instanced static meshes, but that turned out to be a “mess” (i.e. way too much overhead to manage those instances). It feels that both these approaches are not the best way to go, at least my guts tell me to not cut the terrain into thousands of tiles. So I am asking you guys, if I use just one single terrain mesh for the whole map, how can I make it look like made of tiles? How can I add grid overlays and highlight one or more more cells/tiles?

Just as a reference, what I am trying to achieve is something like this:

You can see the grid, even though the whole terrain seems to be made of one mesh …

The best way in my opinion is if each tile is a streaming level, because when you remove a streaming level it will automatically remove everything you have linked to it (lights, volumes, meshes, actors, etc), so you can selectively unload the ones too far to be visible at camera view (hopefully not a top view like that, better if more isometric) and load the ones which might be visible according to the gameplay status.

There is this tool which can help with querying elements on top of the grid which would map your streaming levels in position and size: https://unrealengine.com/marketplace…se-grid-plugin (only possible if the streaming level is loaded)

Thanks for your reply. But I am not sure how your suggested approach would solve my issue. Even when using a streaming level for each tile, I would still need a mesh for each fot these levels. So with my large maps I would still end up with thousands of tiles and therefore streaming levels. Is that really a good approach?

I think the problem is not the solutions we can come up, but in fact the large map you want to have. Is it really ideal?

The streaming levels are the way to handle large environments thinking on performance constraints, but I am not sure what you will put there in each tile, so maybe it is overestimated.

If I would build a game similar, I would use a quadtree system if I only care about the plane (X and Y) and not the depth (Z) with each quad being a streaming level. But again, I would define a maximum size for the map if it is multiplayer, big maps in multiplayer are taxing, and some solutions let one server per map just for the sake of consistency and performance.

NilsonLima, I don’t think you are understanding what the question is. In regards to tiles, the op was not asking about level streaming or tile based landscapes. If you look at the picture you can see the grid lines shown on top of the landscape. This is from what I’ve been able to gather just down using a material, but that’s about the only thing I’ve been able to find which is what led me here. One example is if you think back to Sim City or other older rts games. H[FONT=Helvetica,Arial,Verdana,sans-serif][COLOR=#000120]aimat[/COLOR] were you ever able to come up with a solution?

@haimat I think this would be done with on hovered selection if you were getting the mouse.

there is a macro 2d grid execution in the engine I’ve never used it though.has rows of x and y size etc. not sure how to tie in a pointer for grid space

So for now I ended up with having 10x10 grid cells per mesh actor, so one mesh for 100 cells, that seems to work fine performance wise, even for larger maps.

This may help. its pretty cool.
GitHub - RohitKotiveetil/UnrealEngine--GridGenerator: Grid Generation System created using blueprints in Unreal Engine

@thadkinsjr that looks pretty good for grid stuff, keen to try it out

Is there any way I could see how yours works out? Did you just put a grid over landscape? or are your meshes 10x10 cell chunks?
I’ve been creating Static Mesh Instances but I run into problems with materials and adding variety.

Also, is there any good way to blend materials at the edge of different tiles with each other?
Any help would be fantastic.
Thanks,

Hmm… before I found this thread, I made each tile into a blueprint actor, but boy did that tank performance (probably because all meshes in them are now movable instead of static)!

So now, I’m researching how to “bake” all the static meshes out of each tile blueprint actor down to a level “module” consisting of a number of tiles, and then instance them into a larger world.

But is the best answer still to have each tile as a level? And then have levels upon levels? Sorry, using the wrong terminology here, because I haven’t looked into this area of Unreal Engine yet, but it sounds like an extreme amount of levels and I’m unsure how colliders and blueprint logic will work across them (I’m going to have more than 4000 of them at once… depending on how culling will work for this).

EDIT: Ok, made a super simple Editor Utility Widget to copy all staticmesh actors from the blueprint actors to the level, and went from 14k draw calls to 500. :smiley:

@eobet Culling will work fine for the actors, but if each one has some kind of processing (even small) that will affect performance. You will probably need to figure how to turn that processing on/off if the actor is being culled. The idea of copying the static meshes to the level was great result!