Open KoBeWi opened 4 years ago
I am having this problem too trying to get a SimCity/Micropolis style terrain working. I followed this tutorial which was pretty helpful, but it has the same issue we are trying to solve. https://www.davidepesce.com/2019/10/18/godot-tutorial-7-using-tile-maps-to-create-game-map/
Unlike the tutorial game, I am not going for strictly an island. For me it would be useful to just have the edges where there are no tiles be interpreted as if a tile was there of the same type of the tile that is checking. The closest example I can think of to describe this is how Tribes or Battlefield 2's terrain engines for example repeat the terrain off into infinity if you go out of bounds. Essentially we want the same thing but in 2D with tiles.
If I find a workaround, I'll be sure to let you know.
Ideally the following would be possible.
Some of this can be worked around by using the undocumented function:
_is_tile_bound(drawn_id, neighbor_id)
When added to the script of a TileSet, this allows different autotiles to bind to each other, and empty cells report a neighbor id of -1.
So you could add
func _is_tile_bound(drawn_id, neighbor_id):
return neighbor_id == -1
to your tileset, and all empty tiles would be treated as the type that is currently being checked.
Some of this can be worked around by using the undocumented function:
_is_tile_bound(drawn_id, neighbor_id)
When added to the script of a TileSet, this allows different autotiles to bind to each other, and empty cells report a neighbor id of -1.
So you could add
func _is_tile_bound(drawn_id, neighbor_id): return neighbor_id == -1
to your tileset, and all empty tiles would be treated as the type that is currently being checked.
The problem is that there's no way to know where the tile is being drawn, we don't know if it's on the edge. So this code just makes every tile the innermost one.
Some of this can be worked around by using the undocumented function:
_is_tile_bound(drawn_id, neighbor_id)
When added to the script of a TileSet, this allows different autotiles to bind to each other, and empty cells report a neighbor id of -1. So you could addfunc _is_tile_bound(drawn_id, neighbor_id): return neighbor_id == -1
to your tileset, and all empty tiles would be treated as the type that is currently being checked.
The problem is that there's no way to know where the tile is being drawn, we don't know if it's on the edge. So this code just makes every tile the innermost one.
No, binding to "-1" only treats empty cells as active. Cells with a different id would still be considered inactive.
So long as all cells in the used region of your map are non-empty, only edge cells will be adjacent to an empty cell, and so only edge cells would be affected by this code.
Some of this can be worked around by using the undocumented function:
_is_tile_bound(drawn_id, neighbor_id)
When added to the script of a TileSet, this allows different autotiles to bind to each other, and empty cells report a neighbor id of -1. So you could addfunc _is_tile_bound(drawn_id, neighbor_id): return neighbor_id == -1
to your tileset, and all empty tiles would be treated as the type that is currently being checked.
The problem is that there's no way to know where the tile is being drawn, we don't know if it's on the edge. So this code just makes every tile the innermost one.
No, binding to "-1" only treats empty cells as active. Cells with a different id would still be considered inactive.
So long as all cells in the used region of your map are non-empty, only edge cells will be adjacent to an empty cell, and so only edge cells would be affected by this code.
Hm, I tried this and it seems to be reading the other autotile as -1. I don't want to clog up this proposal with support though.
Describe the project you are working on: 2D game with tiles.
Describe the problem or limitation you are having in your project: I defined autotiles for my tileset, but they have problem on the edges. Well, I have problem. Look at this ground at the edge of the map. This is how I want it to look: It's impossible to achieve this with autotiles only. I either need to add some tiles out of the screen, so the border is invisible or disable autotiling to draw what I want (basically killing the purpose of autotiles :/)
Describe how this feature / enhancement will help you overcome this problem or limitation: Would be nice to have an option to treat TileMap edges as "tiles" so autotiles on the edges would behave like if there were tiles next to them.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work: (some option in the inspector that changes what appears in first image into stuff on the second one)
Describe implementation detail for your proposal (in code), if possible: (some TileMap property that changes what appears in first image into stuff on the second one)
If this enhancement will not be used often, can it be worked around with a few lines of script?: Probably doable with a script, not sure how many people would use it, but maybe they don't know yet that they need it.
Is there a reason why this should be core and not an add-on in the asset library?: Makes autotiles more platformer-friendly, so it's like general usage (?).