This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

merge 2 autotiles

boruokboruok Posts: 18Member

It's possible to merge 2 autotile into one?
what i see:

what i want:


Tags :

Comments

  • 2DFanatic2DFanatic Posts: 2Member

    The tile you want as the result of the 2 separate tiles above has a completely different mid section. The merging between tiles should be relatable like using bit-mask for mapping what tile must appear next to another tile while auto tile mapping. I recommend you watch this video for using the tile-set editor :
    https://youtube.com/watch?v=V9OoaOlXc_4
    And this for setting rules for tiles during map generation.
    https://youtube.com/watch?v=SBDs8hbs43w

  • tmctmc Posts: 1Member
    edited March 2020

    This is accomplished by attaching a script to the TileSet which overrides the undocumented _is_tile_bound() virtual method. This method is called (at least) 8 times for each tile, with each of the neighbouring tile IDs, and should return whether those two tiles are considered to be part of the same group of tiles or not.

    It turns out that adding this overload only makes autotiling about 10-20% slower, because it's slow anyway.

    Example:

    extends TileSet
    # "tool" makes this also apply when placing tiles by hand in the tilemap editor too.
    tool
    
    const BRIDGE = 4
    const BRICKS = 5
    const CHASM = 6
    
    var binds = {
        CHASM: [BRIDGE],
        BRIDGE: [BRICKS],
        BRICKS: [BRIDGE],
    }
    
    func _is_tile_bound(id, neighbour_id):
        if id in binds:
            return neighbour_id in binds[id]
        return false
    

    Just chasm tiles:

    Bridge tiles added. Note that the bridge affects the chasm autotiling but not vice-versa.

    Brick ground tiles added. Note that the brick and bridge tiles join together.

  • boruokboruok Posts: 18Member
    edited March 2020

    I really appreciate your help. Thank you.

  • boruokboruok Posts: 18Member
    edited March 2020

    also, if you whant to merge all your AutoTiles in same TileMap, you can use following code:

    tool
    extends TileSet
    
    
    func _is_tile_bound(id, neighbour_id):
        return neighbour_id in get_tiles_ids()
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.