Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special TileMap edge mode for autotiles #310

Open
KoBeWi opened this issue Dec 16, 2019 · 5 comments
Open

Special TileMap edge mode for autotiles #310

KoBeWi opened this issue Dec 16, 2019 · 5 comments

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Dec 16, 2019

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.
image
Look at this ground at the edge of the map. This is how I want it to look:
image
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 (?).

@RobertBColton
Copy link

RobertBColton commented Jan 4, 2020

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.

Autotile Edges

Ideally the following would be possible.

Ideal Edges

@SquiggelSquirrel
Copy link

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.

@tech6hutch
Copy link

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.

@SquiggelSquirrel
Copy link

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.

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.

@tech6hutch
Copy link

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants