Procedural Generation in 2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By schwiftypython
:warning: 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.

:bust_in_silhouette: Reply From: Zylann

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.

Ok, I’ll give those methods a go. Thank you!

schwiftypython | 2016-06-13 17:02

tile_id

what do you mean by tile id? the src?

Sourav Parik | 2020-10-09 11:44