Node for 2D tile-based maps. Node for 2D tile-based maps. Tilemaps use a [TileSet] which contain a list of tiles (textures plus optional collision, navigation, and/or occluder shapes) which are used to create grid-based maps. When doing physics queries against the tilemap, the cell coordinates are encoded as [code]metadata[/code] for each detected collision shape returned by methods such as [method Physics2DDirectSpaceState.intersect_shape], [method Physics2DDirectBodyState.get_contact_collider_shape_metadata], etc. https://docs.godotengine.org/en/3.3/tutorials/2d/using_tilemaps.html https://godotengine.org/asset-library/asset/120 https://godotengine.org/asset-library/asset/112 https://godotengine.org/asset-library/asset/111 https://godotengine.org/asset-library/asset/519 https://godotengine.org/asset-library/asset/520 https://godotengine.org/asset-library/asset/113 Clears all cells. Clears cells that do not exist in the tileset. Returns the tile index of the given cell. If no tile exists in the cell, returns [constant INVALID_CELL]. Returns the coordinate (subtile column and row) of the autotile variation in the tileset. Returns a zero vector if the cell doesn't have autotiling. Returns the tile index of the cell given by a Vector2. If no tile exists in the cell, returns [constant INVALID_CELL]. Returns [code]true[/code] if the given collision layer bit is set. Returns [code]true[/code] if the given collision mask bit is set. Returns a [Vector2] array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from [code]-1[/code]). Returns an array of all cells with the given tile index specified in [code]id[/code]. Returns a rectangle enclosing the used (non-empty) tiles of the map. Returns [code]true[/code] if the given cell is transposed, i.e. the X and Y axes are swapped. Returns [code]true[/code] if the given cell is flipped in the X axis. Returns [code]true[/code] if the given cell is flipped in the Y axis. Returns the local position of the top left corner of the cell corresponding to the given tilemap (grid-based) coordinates. To get the global position, use [method Node2D.to_global]: [codeblock] var local_position = my_tilemap.map_to_world(map_position) var global_position = my_tilemap.to_global(local_position) [/codeblock] Optionally, the tilemap's half offset can be ignored. Sets the tile index for the cell given by a Vector2. An index of [code]-1[/code] clears the cell. Optionally, the tile can also be flipped, transposed, or given autotile coordinates. The autotile coordinate refers to the column and row of the subtile. [b]Note:[/b] Data such as navigation polygons and collision shapes are not immediately updated for performance reasons. If you need these to be immediately updated, you can call [method update_dirty_quadrants]. Overriding this method also overrides it internally, allowing custom logic to be implemented when tiles are placed/removed: [codeblock] func set_cell(x, y, tile, flip_x=false, flip_y=false, transpose=false, autotile_coord=Vector2()): # Write your custom logic here. # To call the default method: .set_cell(x, y, tile, flip_x, flip_y, transpose, autotile_coord) [/codeblock] Sets the tile index for the given cell. An index of [code]-1[/code] clears the cell. Optionally, the tile can also be flipped or transposed. [b]Note:[/b] Data such as navigation polygons and collision shapes are not immediately updated for performance reasons. If you need these to be immediately updated, you can call [method update_dirty_quadrants]. Sets the given collision layer bit. Sets the given collision mask bit. Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based X and Y coordinates. Applies autotiling rules to the cells in the given region (specified by grid-based X and Y coordinates). Calling with invalid (or missing) parameters applies autotiling rules for the entire tilemap. Updates the tile map's quadrants, allowing things such as navigation and collision shapes to be immediately used if modified. Returns the tilemap (grid-based) coordinates corresponding to the given local position. To use this with a global position, first determine the local position with [method Node2D.to_local]: [codeblock] var local_position = my_tilemap.to_local(global_position) var map_position = my_tilemap.world_to_map(local_position) [/codeblock] If [code]true[/code], the cell's UVs will be clipped. The custom [Transform2D] to be applied to the TileMap's cells. Amount to offset alternating tiles. See [enum HalfOffset] for possible values. The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size. The TileMap's cell size. Position for tile origin. See [enum TileOrigin] for possible values. If [code]true[/code], the TileMap's direct children will be drawn in order of their Y coordinate. If [code]true[/code], the textures will be centered in the middle of each tile. This is useful for certain isometric or top-down modes when textures are made larger or smaller than the tiles (e.g. to avoid flickering on tile edges). The offset is still applied, but from the center of the tile. If used, [member compatibility_mode] is ignored. If [code]false[/code], the texture position start in the top-left corner unless [member compatibility_mode] is enabled. Bounce value for static body collisions (see [code]collision_use_kinematic[/code]). Friction value for static body collisions (see [code]collision_use_kinematic[/code]). The collision layer(s) for all colliders in the TileMap. See [url=https://docs.godotengine.org/en/3.3/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. The collision mask(s) for all colliders in the TileMap. See [url=https://docs.godotengine.org/en/3.3/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. If [code]true[/code], TileMap collisions will be handled as a kinematic body. If [code]false[/code], collisions will be handled as static body. If [code]true[/code], this tilemap's collision shape will be added to the collision shape of the parent. The parent has to be a [CollisionObject2D]. If [code]true[/code], the compatibility with the tilemaps made in Godot 3.1 or earlier is maintained (textures move when the tile origin changes and rotate if the texture size is not homogeneous). This mode presents problems when doing [code]flip_h[/code], [code]flip_v[/code] and [code]transpose[/code] tile operations on non-homogeneous isometric tiles (e.g. 2:1), in which the texture could not coincide with the collision, thus it is not recommended for isometric or non-square tiles. If [code]false[/code], the textures do not move when doing [code]flip_h[/code], [code]flip_v[/code] operations if no offset is used, nor when changing the tile origin. The compatibility mode doesn't work with the [member centered_textures] option, because displacing textures with the [member cell_tile_origin] option or in irregular tiles is not relevant when centering those textures. The TileMap orientation mode. See [enum Mode] for possible values. The light mask assigned to all light occluders in the TileMap. The TileSet's light occluders will cast shadows only from Light2D(s) that have the same light mask(s). If [code]true[/code], collision shapes are visible in the editor. Doesn't affect collision shapes visibility at runtime. To show collision shapes at runtime, enable [b]Visible Collision Shapes[/b] in the [b]Debug[/b] menu instead. The assigned [TileSet]. Emitted when a tilemap setting has changed. Returned when a cell doesn't exist. Orthogonal orientation mode. Isometric orientation mode. Custom orientation mode. Half offset on the X coordinate. Half offset on the Y coordinate. Half offset disabled. Half offset on the X coordinate (negative). Half offset on the Y coordinate (negative). Tile origin at its top-left corner. Tile origin at its center. Tile origin at its bottom-left corner.