Tile library for tilemaps.
A TileSet is a library of tiles for a TileMapLayer. A TileSet handles a list of TileSetSource, each of them storing a set of tiles.
Tiles can either be from a TileSetAtlasSource, which renders tiles out of a texture with support for physics, navigation, etc., or from a TileSetScenesCollectionSource, which exposes scene-based tiles.
Tiles are referenced by using three IDs: their source ID, their atlas coordinates ID, and their alternative tile ID.
A TileSet can be configured so that its tiles expose more or fewer properties. To do so, the TileSet resources use property layers, which you can add or remove depending on your needs.
For example, adding a physics layer allows giving collision shapes to your tiles. Each layer has dedicated properties (physics layer and mask), so you may add several TileSet physics layers for each type of collision you need.
See the functions to add new layers for more information.
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), changes the way tiles are indexed in the TileMapLayer grid.
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), determines the offset axis.
The tile size, in pixels. For all tile shapes, this size corresponds to the encompassing rectangle of the tile shape. This is thus the minimal cell size required in an atlas.
Adds a custom data layer to the TileSet at the given position to_position in the array. If to_position is -1, adds it at the end of the array.
Custom data layers allow assigning custom properties to atlas tiles.
Adds an occlusion layer to the TileSet at the given position to_position in the array. If to_position is -1, adds it at the end of the array.
Occlusion layers allow assigning occlusion polygons to atlas tiles.
Adds a TileMapPattern to be stored in the TileSet resource. If provided, insert it at the given index.
Adds a physics layer to the TileSet at the given position to_position in the array. If to_position is -1, adds it at the end of the array.
Physics layers allow assigning collision polygons to atlas tiles.
Adds a TileSetSource to the TileSet. If atlas_source_id_override is not -1, also set its source ID. Otherwise, a unique identifier is automatically generated.
The function returns the added source ID or -1 if the source could not be added.
Warning: A source cannot belong to two TileSets at the same time. If the added source was attached to another TileSet, it will be removed from that one.
Adds a new terrain to the given terrain set terrain_set at the given position to_position in the array. If to_position is -1, adds it at the end of the array.
Adds a new terrain set at the given position to_position in the array. If to_position is -1, adds it at the end of the array.
Returns the alternative-level proxy for the given identifiers. The returned array contains the three proxie's target identifiers (source ID, atlas coords ID and alternative tile ID).
If the TileSet has no proxy for the given identifiers, returns an empty Array.
Returns the coordinate-level proxy for the given identifiers. The returned array contains the two target identifiers of the proxy (source ID and atlas coordinates ID).
If the TileSet has no proxy for the given identifiers, returns an empty Array.
Returns a new unused source ID. This generated ID is the same that a call to add_source() would return.
Returns the collision layer (as in the physics server) bodies on the given TileSet's physics layer are in.
Returns the source-level proxy for the given source identifier.
If the TileSet has no proxy for the given identifier, returns -1.
Returns if there is an alternative-level proxy for the given identifiers.
According to the configured proxies, maps the provided identifiers to a new set of identifiers. The source ID, atlas coordinates ID and alternative tile ID are returned as a 3 elements Array.
This function first look for matching alternative-level proxies, then coordinates-level proxies, then source-level proxies.
If no proxy corresponding to provided identifiers are found, returns the same values the ones used as arguments.
Moves the custom data layer at index layer_index to the given position to_position in the array. Also updates the atlas tiles accordingly.
Moves the occlusion layer at index layer_index to the given position to_position in the array. Also updates the atlas tiles accordingly.
Moves the physics layer at index layer_index to the given position to_position in the array. Also updates the atlas tiles accordingly.
Moves the terrain at index terrain_index for terrain set terrain_set to the given position to_position in the array. Also updates the atlas tiles accordingly.
Moves the terrain set at index terrain_set to the given position to_position in the array. Also updates the atlas tiles accordingly.
Removes an alternative-level proxy for the given identifiers.
Removes the terrain at index terrain_index in the given terrain set terrain_set. Also updates the atlas tiles accordingly.
Create an alternative-level proxy for the given identifiers. A proxy will map set of tile identifiers to another set of identifiers.
Proxied tiles can be automatically replaced in TileMapLayer nodes using the editor.
Creates a coordinates-level proxy for the given identifiers. A proxy will map set of tile identifiers to another set of identifiers. The alternative tile ID is kept the same when using coordinates-level proxies.
Proxied tiles can be automatically replaced in TileMapLayer nodes using the editor.
Sets the name of the custom data layer identified by the given index. Names are identifiers of the layer therefore if the name is already taken it will fail and raise an error.
Sets the occlusion layer (as in the rendering server) for occluders in the given TileSet occlusion layer.
Sets the physics material for bodies in the given TileSet physics layer.
Creates a source-level proxy for the given source ID. A proxy will map set of tile identifiers to another set of identifiers. Both the atlas coordinates ID and the alternative tile ID are kept the same when using source-level proxies.
Proxied tiles can be automatically replaced in TileMapLayer nodes using the editor.
Sets a terrain's color. This color is used for identifying the different terrains in the TileSet editor.
Sets a terrain mode. Each mode determines which bits of a tile shape is used to match the neighboring tiles' terrains.
TILE_SHAPE_SQUARE = 0Rectangular tile shape.
TILE_SHAPE_ISOMETRIC = 1Diamond tile shape (for isometric look).
Note: Isometric TileSet works best if all sibling TileMapLayers and their parent inheriting from Node2D have Y-sort enabled.
TILE_SHAPE_HALF_OFFSET_SQUARE = 2Rectangular tile shape with one row/column out of two offset by half a tile.
TILE_SHAPE_HEXAGON = 3Hexagonal tile shape.
TILE_LAYOUT_STACKED = 0Tile coordinates layout where both axis stay consistent with their respective local horizontal and vertical axis.
TILE_LAYOUT_STACKED_OFFSET = 1Same as TILE_LAYOUT_STACKED, but the first half-offset is negative instead of positive.
TILE_LAYOUT_STAIRS_RIGHT = 2Tile coordinates layout where the horizontal axis stay horizontal, and the vertical one goes down-right.
TILE_LAYOUT_STAIRS_DOWN = 3Tile coordinates layout where the vertical axis stay vertical, and the horizontal one goes down-right.
TILE_LAYOUT_DIAMOND_RIGHT = 4Tile coordinates layout where the horizontal axis goes up-right, and the vertical one goes down-right.
TILE_LAYOUT_DIAMOND_DOWN = 5Tile coordinates layout where the horizontal axis goes down-right, and the vertical one goes down-left.
TILE_OFFSET_AXIS_HORIZONTAL = 0Horizontal half-offset.
TILE_OFFSET_AXIS_VERTICAL = 1Vertical half-offset.
CELL_NEIGHBOR_RIGHT_SIDE = 0Neighbor on the right side.
CELL_NEIGHBOR_RIGHT_CORNER = 1Neighbor in the right corner.
CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE = 2Neighbor on the bottom right side.
CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER = 3Neighbor in the bottom right corner.
CELL_NEIGHBOR_BOTTOM_SIDE = 4Neighbor on the bottom side.
CELL_NEIGHBOR_BOTTOM_CORNER = 5Neighbor in the bottom corner.
CELL_NEIGHBOR_BOTTOM_LEFT_SIDE = 6Neighbor on the bottom left side.
CELL_NEIGHBOR_BOTTOM_LEFT_CORNER = 7Neighbor in the bottom left corner.
CELL_NEIGHBOR_LEFT_SIDE = 8Neighbor on the left side.
CELL_NEIGHBOR_LEFT_CORNER = 9Neighbor in the left corner.
CELL_NEIGHBOR_TOP_LEFT_SIDE = 10Neighbor on the top left side.
CELL_NEIGHBOR_TOP_LEFT_CORNER = 11Neighbor in the top left corner.
CELL_NEIGHBOR_TOP_SIDE = 12Neighbor on the top side.
CELL_NEIGHBOR_TOP_CORNER = 13Neighbor in the top corner.
CELL_NEIGHBOR_TOP_RIGHT_SIDE = 14Neighbor on the top right side.
CELL_NEIGHBOR_TOP_RIGHT_CORNER = 15Neighbor in the top right corner.
TERRAIN_MODE_MATCH_CORNERS_AND_SIDES = 0Requires both corners and side to match with neighboring tiles' terrains.
TERRAIN_MODE_MATCH_CORNERS = 1Requires corners to match with neighboring tiles' terrains.
TERRAIN_MODE_MATCH_SIDES = 2Requires sides to match with neighboring tiles' terrains.