Topic was automatically imported from the old Question2Answer platform.
Asked By
schwiftypython
Old Version
Published before Godot 3 was released.
Hey everyone,
Been messing around with 2D and i wanted to generate a world similar to how Gnomoria does. I’ve done something similar in Unity a while back, but I’m having trouble wrapping my head around how to do it the “right” way in godot.
Is it best to make a tileset and create a sprite for each block and grab the corresponding tile? I guess if I did it that way I could add it to an existing tilemap at a Vector2D coordinate.
I’ve been poking around, but haven’t found any resources on how to do this in 2D. Any help would be appreciated. Thank you.
It looks like Gnomoria has a concept of 3D, althought the world is displayed in 2D.
In both cases, you will have to create TileMap and a TileSet as usual, but instead of editing the map in the editor, you set the cells through code, with tilemap.set_cell(x, y, tile_id).
If you want 3D, the process is similar, with the GridMap node.
As for the procedural generation itself, you can put a script on the Tilemap (or on a child “generator” node) that will generate the world and set the tiles. You can look for Perlin/Simplex/OpenSimplex noise techniques for the terrain.