Up to date
This page is up to date for Godot 4.1
.
If you still find outdated information, please open an issue.
TileSet¶
Inherits: Resource < RefCounted < Object
Tile library for tilemaps.
Description¶
A TileSet is a library of tiles for a TileMap. A TileSet handles a list of TileSetSource, each of them storing a set of tiles.
Tiles can either be from a TileSetAtlasSource, that render 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 less properties. To do so, the TileSet resources uses property layers, that you can add or remove depending on your needs.
For example, adding a physics layer allows giving collision shapes to your tiles. Each layer having dedicated properties (physics layer and mask), you may add several TileSet physics layers for each type of collision you need.
See the functions to add new layers for more information.
Tutorials¶
Properties¶
|
||
|
||
|
||
|
||
|
Methods¶
void |
add_custom_data_layer ( int to_position=-1 ) |
void |
add_navigation_layer ( int to_position=-1 ) |
void |
add_occlusion_layer ( int to_position=-1 ) |
add_pattern ( TileMapPattern pattern, int index=-1 ) |
|
void |
add_physics_layer ( int to_position=-1 ) |
add_source ( TileSetSource source, int atlas_source_id_override=-1 ) |
|
void |
add_terrain ( int terrain_set, int to_position=-1 ) |
void |
add_terrain_set ( int to_position=-1 ) |
void |
|
void |
|
get_alternative_level_tile_proxy ( int source_from, Vector2i coords_from, int alternative_from ) |
|
get_coords_level_tile_proxy ( int source_from, Vector2i coords_from ) |
|
get_custom_data_layer_by_name ( String layer_name ) const |
|
get_custom_data_layer_name ( int layer_index ) const |
|
get_custom_data_layer_type ( int layer_index ) const |
|
get_custom_data_layers_count ( ) const |
|
get_navigation_layer_layer_value ( int layer_index, int layer_number ) const |
|
get_navigation_layer_layers ( int layer_index ) const |
|
get_navigation_layers_count ( ) const |
|
get_next_source_id ( ) const |
|
get_occlusion_layer_light_mask ( int layer_index ) const |
|
get_occlusion_layer_sdf_collision ( int layer_index ) const |
|
get_occlusion_layers_count ( ) const |
|
get_pattern ( int index=-1 ) |
|
get_physics_layer_collision_layer ( int layer_index ) const |
|
get_physics_layer_collision_mask ( int layer_index ) const |
|
get_physics_layer_physics_material ( int layer_index ) const |
|
get_physics_layers_count ( ) const |
|
get_source ( int source_id ) const |
|
get_source_count ( ) const |
|
get_source_id ( int index ) const |
|
get_source_level_tile_proxy ( int source_from ) |
|
get_terrain_color ( int terrain_set, int terrain_index ) const |
|
get_terrain_name ( int terrain_set, int terrain_index ) const |
|
get_terrain_set_mode ( int terrain_set ) const |
|
get_terrain_sets_count ( ) const |
|
get_terrains_count ( int terrain_set ) const |
|
has_alternative_level_tile_proxy ( int source_from, Vector2i coords_from, int alternative_from ) |
|
has_coords_level_tile_proxy ( int source_from, Vector2i coords_from ) |
|
has_source ( int source_id ) const |
|
has_source_level_tile_proxy ( int source_from ) |
|
map_tile_proxy ( int source_from, Vector2i coords_from, int alternative_from ) const |
|
void |
move_custom_data_layer ( int layer_index, int to_position ) |
void |
move_navigation_layer ( int layer_index, int to_position ) |
void |
move_occlusion_layer ( int layer_index, int to_position ) |
void |
move_physics_layer ( int layer_index, int to_position ) |
void |
move_terrain ( int terrain_set, int terrain_index, int to_position ) |
void |
move_terrain_set ( int terrain_set, int to_position ) |
void |
remove_alternative_level_tile_proxy ( int source_from, Vector2i coords_from, int alternative_from ) |
void |
remove_coords_level_tile_proxy ( int source_from, Vector2i coords_from ) |
void |
remove_custom_data_layer ( int layer_index ) |
void |
remove_navigation_layer ( int layer_index ) |
void |
remove_occlusion_layer ( int layer_index ) |
void |
remove_pattern ( int index ) |
void |
remove_physics_layer ( int layer_index ) |
void |
remove_source ( int source_id ) |
void |
remove_source_level_tile_proxy ( int source_from ) |
void |
remove_terrain ( int terrain_set, int terrain_index ) |
void |
remove_terrain_set ( int terrain_set ) |
void |
set_alternative_level_tile_proxy ( int source_from, Vector2i coords_from, int alternative_from, int source_to, Vector2i coords_to, int alternative_to ) |
void |
set_coords_level_tile_proxy ( int p_source_from, Vector2i coords_from, int source_to, Vector2i coords_to ) |
void |
set_custom_data_layer_name ( int layer_index, String layer_name ) |
void |
set_custom_data_layer_type ( int layer_index, Variant.Type layer_type ) |
void |
set_navigation_layer_layer_value ( int layer_index, int layer_number, bool value ) |
void |
set_navigation_layer_layers ( int layer_index, int layers ) |
void |
set_occlusion_layer_light_mask ( int layer_index, int light_mask ) |
void |
set_occlusion_layer_sdf_collision ( int layer_index, bool sdf_collision ) |
void |
set_physics_layer_collision_layer ( int layer_index, int layer ) |
void |
set_physics_layer_collision_mask ( int layer_index, int mask ) |
void |
set_physics_layer_physics_material ( int layer_index, PhysicsMaterial physics_material ) |
void |
set_source_id ( int source_id, int new_source_id ) |
void |
set_source_level_tile_proxy ( int source_from, int source_to ) |
void |
set_terrain_color ( int terrain_set, int terrain_index, Color color ) |
void |
set_terrain_name ( int terrain_set, int terrain_index, String name ) |
void |
set_terrain_set_mode ( int terrain_set, TerrainMode mode ) |
Enumerations¶
enum TileShape:
TileShape TILE_SHAPE_SQUARE = 0
Rectangular tile shape.
TileShape TILE_SHAPE_ISOMETRIC = 1
Diamond tile shape (for isometric look).
Note: Isometric TileSet works best if TileMap and all its layers have Y-sort enabled.
TileShape TILE_SHAPE_HALF_OFFSET_SQUARE = 2
Rectangular tile shape with one row/column out of two offset by half a tile.
TileShape TILE_SHAPE_HEXAGON = 3
Hexagonal tile shape.
enum TileLayout:
TileLayout TILE_LAYOUT_STACKED = 0
Tile coordinates layout where both axis stay consistent with their respective local horizontal and vertical axis.
TileLayout TILE_LAYOUT_STACKED_OFFSET = 1
Same as TILE_LAYOUT_STACKED, but the first half-offset is negative instead of positive.
TileLayout TILE_LAYOUT_STAIRS_RIGHT = 2
Tile coordinates layout where the horizontal axis stay horizontal, and the vertical one goes down-right.
TileLayout TILE_LAYOUT_STAIRS_DOWN = 3
Tile coordinates layout where the vertical axis stay vertical, and the horizontal one goes down-right.
TileLayout TILE_LAYOUT_DIAMOND_RIGHT = 4
Tile coordinates layout where the horizontal axis goes up-right, and the vertical one goes down-right.
TileLayout TILE_LAYOUT_DIAMOND_DOWN = 5
Tile coordinates layout where the horizontal axis goes down-right, and the vertical one goes down-left.
enum TileOffsetAxis:
TileOffsetAxis TILE_OFFSET_AXIS_HORIZONTAL = 0
Horizontal half-offset.
TileOffsetAxis TILE_OFFSET_AXIS_VERTICAL = 1
Vertical half-offset.
enum CellNeighbor:
CellNeighbor CELL_NEIGHBOR_RIGHT_SIDE = 0
Neighbor on the right side.
CellNeighbor CELL_NEIGHBOR_RIGHT_CORNER = 1
Neighbor in the right corner.
CellNeighbor CELL_NEIGHBOR_BOTTOM_RIGHT_SIDE = 2
Neighbor on the bottom right side.
CellNeighbor CELL_NEIGHBOR_BOTTOM_RIGHT_CORNER = 3
Neighbor in the bottom right corner.
CellNeighbor CELL_NEIGHBOR_BOTTOM_SIDE = 4
Neighbor on the bottom side.
CellNeighbor CELL_NEIGHBOR_BOTTOM_CORNER = 5
Neighbor in the bottom corner.
CellNeighbor CELL_NEIGHBOR_BOTTOM_LEFT_SIDE = 6
Neighbor on the bottom left side.
CellNeighbor CELL_NEIGHBOR_BOTTOM_LEFT_CORNER = 7
Neighbor in the bottom left corner.
CellNeighbor CELL_NEIGHBOR_LEFT_SIDE = 8
Neighbor on the left side.
CellNeighbor CELL_NEIGHBOR_LEFT_CORNER = 9
Neighbor in the left corner.
CellNeighbor CELL_NEIGHBOR_TOP_LEFT_SIDE = 10
Neighbor on the top left side.
CellNeighbor CELL_NEIGHBOR_TOP_LEFT_CORNER = 11
Neighbor in the top left corner.
CellNeighbor CELL_NEIGHBOR_TOP_SIDE = 12
Neighbor on the top side.
CellNeighbor CELL_NEIGHBOR_TOP_CORNER = 13
Neighbor in the top corner.
CellNeighbor CELL_NEIGHBOR_TOP_RIGHT_SIDE = 14
Neighbor on the top right side.
CellNeighbor CELL_NEIGHBOR_TOP_RIGHT_CORNER = 15
Neighbor in the top right corner.
enum TerrainMode:
TerrainMode TERRAIN_MODE_MATCH_CORNERS_AND_SIDES = 0
Requires both corners and side to match with neighboring tiles' terrains.
TerrainMode TERRAIN_MODE_MATCH_CORNERS = 1
Requires corners to match with neighboring tiles' terrains.
TerrainMode TERRAIN_MODE_MATCH_SIDES = 2
Requires sides to match with neighboring tiles' terrains.
Property Descriptions¶
TileLayout tile_layout = 0
void set_tile_layout ( TileLayout value )
TileLayout get_tile_layout ( )
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), changes the way tiles are indexed in the TileMap grid.
TileOffsetAxis tile_offset_axis = 0
void set_tile_offset_axis ( TileOffsetAxis value )
TileOffsetAxis get_tile_offset_axis ( )
For all half-offset shapes (Isometric, Hexagonal and Half-Offset square), determines the offset axis.
TileShape tile_shape = 0
The tile shape.
Vector2i tile_size = Vector2i(16, 16)
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.
bool uv_clipping = false
Enables/Disable uv clipping when rendering the tiles.
Method Descriptions¶
void add_custom_data_layer ( int to_position=-1 )
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 a navigation 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.
Navigation layers allow assigning a navigable area to atlas tiles.
void add_occlusion_layer ( int to_position=-1 )
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.
int add_pattern ( TileMapPattern pattern, int index=-1 )
Adds a TileMapPattern to be stored in the TileSet resource. If provided, insert it at the given index
.
void add_physics_layer ( int to_position=-1