• 2D
  • How do I place very large amounts of tiles in a tilemap?

I currently have a project that uses open simplex noise to generate a world made up of pixels (each tile is one pixel). As of now, the noise determines whether or not a tile should be placed within a giving area (world size) and then places one there, simple. The issue is, after a certain world size, the game becomes unresponsive when attempting to load that scene. After some testing, I have found that I can procedurally generate a world of exactly 2305x2305 pixels, but anything after that causes the game to not respond. Weirdly, 2305x2305 consistently runs, but 2306x2306 will always crash, so I don't think it's a performance issue. I've tried rectangular worlds, and can run generation of a 4000x400 size world that ran fine, but a 4000x4000 world won't. No matter the size, I have always been able to run the world (with a character) at 60+ fps. My question is; what's stopping me from generating larger world sizes? And, is this is how I should go about doing it? I don't know if a tilemap is the best way to go about generating a world where each pixel is minable either, so I would appreciate any feedback on better ways to generate said world. I'm attempting to make a game similar to Noita but about mining. If you need any of the code, then please let me know. Thank you for reading and possibly responding!

Oh oh oh me me me! I just read this and obviously have to share it with you! Hope it helps!

Generate your world in chunks, say for an example 512x512 or 1024x1024 in size. then spawn those chunks in dynamically so you only load in what the player needs to see.

edit: to be clear I expect you to use a different/new tilemap for each chunk in case that wasn't obvious.

Maybe Tilemap is not the best option. I would recommend just using Sprites with a MultiMeshInstance. You should be able to have a lot of them. I did a demo with MultiMeshInstance3D with 100,000 textured cubes and still got over 900 fps. In 2D you could probably have much more.

@cybereality said: Maybe Tilemap is not the best option. I would recommend just using Sprites with a MultiMeshInstance. You should be able to have a lot of them. I did a demo with MultiMeshInstance3D with 100,000 textured cubes and still got over 900 fps. In 2D you could probably have much more.

I had read someone else's post where you had said that and was looking into it. Thank you! I'll try that out.

@Megalomaniak said: Generate your world in chunks, say for an example 512x512 or 1024x1024 in size. then spawn those chunks in dynamically so you only load in what the player needs to see.

edit: to be clear I expect you to use a different/new tilemap for each chunk in case that wasn't obvious.

I was thinking about that. However, I was wondering what the difference between making your own chunk loading was vs using the built-in quadrant system. I was leaning against using a chunk loading system since Terraria (whose worlds are similar to my own and much bigger currently) doesn't use one and has very little optimization, yet it runs fine. I believe that what I'm struggling with is less of a performance issue and more of a technical issue since I can run the simulation flawlessly with no hiccups and the quadrant system seems to work fine, at least according to the debugger. I'm just failing to understand how it works completely fine and normal every single time right up until a very specific size. Anyways, I will look more into that and try it out if it comes down to it. Thank you for the feedback. :)

@Erich_L said: Oh oh oh me me me! I just read this and obviously have to share it with you! Hope it helps!

Thank you! I'll make sure to read that :)

@"Bloody Spuddy Buddy" said: I was leaning against using a chunk loading system since Terraria (whose worlds are similar to my own and much bigger currently) doesn't use one and has very little optimization, yet it runs fine.

Terrarias world size is pretty limited though, event the biggest world size is relatively tiny. But big enough for the purposes of the game of course. Still it's not as if I told you how many chunks to have or how big of a world to make that's up to you. ;)

Going with a chunk based solution would simply give you a robust generic solution you should be able to reuse for any other project too.

@Megalomaniak said:

@"Bloody Spuddy Buddy" said: I was leaning against using a chunk loading system since Terraria (whose worlds are similar to my own and much bigger currently) doesn't use one and has very little optimization, yet it runs fine.

Terrarias world size is pretty limited though, event the biggest world size is relatively tiny. But big enough for the purposes of the game of course. Still it's not as if I told you how many chunks to have or how big of a world to make that's up to you. ;)

Going with a chunk based solution would simply give you a robust generic solution you should be able to reuse for any other project too.

Alright, thank you, that makes sense. I'll do that if meshinstance2d doesn't work well (not a lot of documentation on that).

2 years later