Replies: 1 comment 1 reply
-
Regarding TileMapPatterns: Those patterns that you can apply in the TileMap are part of the TileSet that is used by the TileMap. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm new to Godot, but I've stumbled across some headaches and issues regarding the Patterns API. Here's my use case that brought me to this point:
I want to, as a player in my game, set down tiles on an existing tilemap, replacing tiles that are already on the given layer. But I don't want to do it one tile at a time, and want predefined tile shapes and patterns the player can set down. I also want to have the tile shape follow the cursor as a "preview" of what they're going to set down.
Tile Placement and TileMap Patterns
Currently, as far as I'm aware, the Pattern API allows you to simply:
set_pattern
function, which takes a layer, position, and a TileMapPattern objectget_pattern
function, which allows you to programmatically create a pattern for alayer
(?) and drawn out via an array of vectors.Currently,
get_pattern
is rather niche. I understand its use is to go to a layer and manually create aTileMapPattern
from what's available in the game world, and then allowing you to use that pattern. But this is extremely roundabout in many cases.What is sorely needed is a way to extract the available, saved patterns in the
TileMap
Node in the editor. In the TileMap tab, under the Patterns tab where you can draw and paint using those patterns, these patterns each already have indices and are clearly stored as variables somewhere. I think I should be able to, in code, call something like$TileMap.patterns[0]
to get the 1st pattern defined in that Node, of typeTileMapPattern
that could then be used in theset_pattern
function.Tile Preview and Sprite2D Region Rects
NOTE: Quick edit, as I'm realizing that the following only applies to auto-defined regions. Since it gives you multiple rects to "select" from but otherwise don't exist. In this vein, I do think this should change, but it may sound very similar to an Atlas at that point. So feel free to disregard this part if it makes no sense.
My attempt at solving the preview is currently using a sprite2d node that follows the cursor and has the texture that is a tileset of my available shapes (yes, I have bounced between using patterns or just a tileset shape for each shape because of this issue). So I'm using the spritesheet as the texture and making it a region rect where I select all the regions and pick which one I want.
The issue is there's no way to programmatically switch between the rects 'saved' in the sprite2d. You can access the currently active region rect, but there's no way to say "okay, this sprite2d has 4 saved regions with these coordinates" and change the current region rect between them on the fly. I think this could look similar to the above.
Conclusion
Again, I'm new, have no knowledge of the Godot codebase, and maybe these issues are better solved with other patterns or methods. But I do think these are valid suggestions given that I've found myself stuck and unable to implement something in a way that seemed intuitive to me.
Beta Was this translation helpful? Give feedback.
All reactions