| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Path finder for unitys tile system.
With this script you have the ability to create your tilemap using unity's built in tile mapping tools and have A* pathfinding for gameobjects on the grid.
These instructions will get tilebased A* pathfinding up and running in your unity project.
Requires Unity 2017.2 or newer.
You will need to add two new tags to your project: One for tiles that block pathfinding (set to "Blocking" by default) and one that indicates a tile is walkable (set to "Floor" by default).
You will need to import these three files into your unity project: Node.cs NodeGrid.cs Pathfinder.cs
You can use the PathfinderDemo.cs as an example template to create your own pathfinding scripts.
You can access the pathfinder from any MonoBehaviour script by using the TilePathFinder namespace.
using TilePathFinder;In the Start() function create and store a new pathFinder object passing it your tile grid object, a string containing your blocking layers tag and a string containing your floors tag.
pathFinder = new TilePathfinder(GridObject, "Blocking", "Floor");This will create a nodegrid based on the tilemap layers found in the grid object.
Using the new pathfinder object you can now call the FindPath method to get an ordered list of tile locations that lead to the target location. The FindPath method requires a starting point (Vector3Int) and an endpoint (Vector3Int) as input, and will return an ordered list of points that (List) make a path from the start point to the endpoint.
List<Vector3Int> path = TilePathFinder.FindPath(startPoint, endPoint);The unity method WorldToCell() can be used to convert a world position to a cell position (Vector3Int) to be used as input.
Vector3Int startPoint = TileGrid.WorldToCell(transform.position);See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details
| Back | FazBrowse Home | New Git URL |