This blurb about Godot’s TileSet Patterns is purely so search engines pick it up, and unfortunate souls that find themselves in the same position I was in, don’t end up wasting a lot of time.
The interface in which you create and manage tilemap/tileset patterns is confusing at best, and dangerous at worst.
- Patterns are created through the TileMap interface, but actually belong to a TileSet.
- Patterns are referenced in code by index. Indexes are not fixed. Deleting a pattern with the delete key, which has no prompt, will reorder all the patterns.
- Referencing patterns in code can only be referenced by index. You can see how this is a problem with the above issue.
- Patterns are saved offset by the first top-left non-empty tile. This makes it impossible to create patterns that contain empty tiles around them, or to offset patterns in a specific way.
- Patterns can only save a single layer at a time.
- There is no way to edit a pattern.
If you take away one thing from this, DO NOT EVER DELETE A PATTERN. I had dozens of patterns defined, and deleted one to recreate it only to find all my in-code references immediately broke. The only way to fix this was to manually edit and change the indexes in the TileSet resource file.
Godot is amazing, and the tilemap support in general is fantastic. I’ll still continue to use the patterns, but I hope they are updated to be more flexible and safe to use in the future.