godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.77k stars 3.07k forks source link

Get Tilepattern from tilemap #7756

Open st4rl1ght1337 opened 1 year ago

st4rl1ght1337 commented 1 year ago

4.1

Need documentation on how to programmatically get defined tilemappattern from tilemap. Not tilemap.get which creates a new tilepattern. Tilepattern from the UI.

See: https://docs.godotengine.org/en/stable/classes/class_tilemappattern.html#class-tilemappattern https://ask.godotengine.org/155462/how-do-you-get-a-tilemap-pattern-that-you-created

st4rl1ght1337 commented 1 year ago

From @Triberium (on discord)

TileMap.tile_set.get_pattern(idx: int)
it returns a TileMapPattern

this worked for me with the following code

var pattern = tilemap.tile_set.get_pattern(1) (1 is the index # for the pattern I want to call)
tilemap.set_pattern(1, position, pattern)