Identifying straight lines of identical tiles in a tilemap (then spawning object to fill the space)

0 favourites
  • 3 posts
From the Asset Store
An educational game for Fill in the Blanks. An easy to use template for developers to build larger games
  • So I'm trying to optimize my dungeon generation. Currently I use a similar method to the "3D Castle Maze" example. I generate a tilemap at runtime that then creates 3D objects as solid walls on each applicable tile.

    However ideally I would like to optimize this further. Because my generated dungeons can be quite large and complex, and because I am spawning hundreds of enemies, I do start to see performance drops when I reach 900+ objects.

    One way to reduce the number of 3D objects is to identify straight lines of repeating tiles and create a single 3D object that is the length/width of those identical tiles (plus their corners) instead of one 3D object per tile.

    I have an over complicated, very broken version of this already so I'm hoping someone can point me to a simpler solution to this. Currently I ID every "corner" tile and repeat a check in 1 direction for that corner until it ID's a different corner, and spawn the 3D object based on that information. Unfortunately this is really complicated and falls apart a bit at some weirder junctions you can see in the screenshot below:

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here's one solution just that creates sprites covering horizontal and vertical runs of the same tile. Used an array to mark tiles that were already used.

    dropbox.com/scl/fi/l78tvqp8lz6oyo7fojcck/runs_of_tilemap_tiles.capx

  • Thank you so much for the reply R0J0hound!

    It took a bit of futzing with, but I did get it running in my game and I am pretty happy with the results. For anyone who hopes to do this in the future with 3D shapes as I did, the easiest way is to basically just copy your example and then add a "for each sprite" event afterward that replaces each sprite with your 3d shape and updates its size to reflect it. Make sure you add a centered image point to your sprite and spawn the 3D shape there. I spent a couple hours trying to spawn the 3D shape instead of a sprite and just offset it but that never worked properly for me.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)