Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets
Packages
PreviewImages
ProjectSettings
.gitignore
LICENSE
README.md

README.md

Breadth First Search and Breadth First Traversal

The Breadth First Search and Breadth First Traversal code can be found in the TilemapExtension.cs.

To use the Breadth First algorithms you need to pass it a starting place and a isConnected method which tells the algorithms if the next cell in the grid should be considered or not. The following code snippet tells the algorithm to consider empty cells within bounds to be valid.

List<Vector3Int> cells = tilemap.BreadthFirstTraversal(start, (current, next) =>
{
    return tilemap.cellBounds.Contains(next) && tilemap.GetTile(next) == null;
});

This project has an example scene which highlights all tiles that can be reached within 8 steps from a random starting place in the grid.

You can’t perform that action at this time.