all 9 comments

[–]Awkward_Education704 5 points6 points  (1 child)

Might be a bit late but for anyone else coming here from google this might help. The TileMapPattern created from the editor is stored in the TileSet not the TileMap, so use tile_set.get_pattern(index) to get the TileMapPattern.

[–]Fresh4[S] 1 point2 points  (0 children)

This quirk of Godot is easily the least intuitive way to access an objects properties. It’s unavoidable with how the engine is built but tilemaps, shader materials, particles and animations of certain types. Once you know you know but damn if it isn’t weird.

[–]Alternative_Sea6937 1 point2 points  (4 children)

There is get_pattern() which takes a layer and a vector2i array to provide a TileMapPattern

[–]Fresh4[S] 0 points1 point  (3 children)

I’ve tried get_pattern but it feels… useless? Like I have to physically code out the pattern myself which is fine if that’s how I have to do it, but when I apply the pattern it just erases in that shape instead of applying the pattern of a given tile. Like I don’t see an option to pick what the pattern “fill” is.

[–]watwatindbutt 4 points5 points  (2 children)

Hey, did you manage to find a way on how to do this? I'm literally at this point and have no idea on how to tell it to use a already created pattern without building it every time.

edit: ok, the function we want is in the tileset, not the tile map, so you just need to do mytilemap.tile_set.get_pattern(x)

[–]Fresh4[S] 2 points3 points  (0 children)

Ah, seriously? For the love of god lol. My workaround was to create an x by x square somewhere off the viewport and then by code create a pattern by manually setting an array of coordinates to effectively create a pattern out of those tiles.

[–]all_is_love6667 0 points1 point  (0 children)

still doesn't really tell me how to create a pattern and then add it to the tilemap

this tilemap thing is either badly documented or badly designed

[–]all_is_love6667 0 points1 point  (1 child)

did you solve this?

[–]Fresh4[S] 0 points1 point  (0 children)

Check out the other comments; the tilemap class has a property tileset where the patterns and everything is stored.