Godot Version
4.3
Question
Simply put, I want to be able to access patterns from this tab:
Inside of gdscript. The method ‘get_pattern’ only gets a pattern at runtime with already placed tiles, rather than letting you get one already manually created.
Please let me know if there are any solutions! Thank you!
So I don’t have a project to test this on but is this what you want.
extends TileMapLayer
var TheLocationOnTheMap:Array[Vector2i]=[Vector2i.ZERO]
var ThePatternOnTheMap:TileMapPattern
var TheLocationInTheSet:int=0
var ThePatternInTheTileSet:TileMapPattern
func _ready() -> void:
ThePatternOnTheMap=get_pattern(TheLocationOnTheMap)
ThePatternOnTheMap=tile_set.get_pattern(TheLocationInTheSet)
Sorry, but this is the problem; this is creating a pattern at runtime rather than using the patterns I manually created in the editor. Is there any way to access those (like the one shown in the image) inside of gdscript?
I found a workaround, but I am not sure I like it all that much. You can create a hidden TileMap node, draw your patterns onto that TileMap, then get the patterns from that tile map and place them in your drawn map. It is not ideal, but it gets the job done. I would much prefer to be able to programmatically access the patterns created in the editor, but I haven’t found a way to do that yet. Might dig through the source code next and see if I can find a back door to that data.
var array: Array = Array()
for x in range(4):
for y in range(3):
array.append (Vector2i(x, y))
var pattern = $templates.get_pattern(array)
set_pattern(Vector2i(2,2), pattern)