This is my diploma work
- Project uses multithreading.
- Non-linear grid! You can reduce tiles count without loose accuracy.
- Simple usage.
- Work with tiles with different passability.
- Bulk pathfinding. Many start positions, one finish.
- Examples branch - look at other small projects
(Requires Unity version 2018.3.0b7 or above)
To install this project as a Git dependency using the Unity Package Manager,
add the following line to your project's manifest.json:
"com.dasik.pathfinding": "https://github.com/Dasik/PathFindingProject.git"
You will need to have Git installed and available in your system's PATH.
Or you can just copy the folder 'Runtime' in your asset scripts folder.
//scan areaCurrentMap.ScanArea(ScanArea.LeftBottomPoint,ScanArea.RightTopPoint,callback:()=>{//remove some areaCurrentMap.RemoveArea(RemoveArea.LeftBottomPoint,RemoveArea.RightTopPoint);});publicclassPathManager:MonoBehaviour{publicPathFindingPathFinder;privateBulkPathTask<AgentScript>bulkPathFinderTask;privateSinglePathTasksinglePathFinderTask;publicAgentScriptagent;publicbooluseBulkPathFinding=true;publicvoidUpdate(){// pathfinding can work with bulk operations. if(useBulkPathFinding){if(bulkPathFinderTask!=null&&bulkPathFinderTask.Status==PathTaskStatus.Completed){foreach(varpathinbulkPathFinderTask.Path){//key is some class that can take a path path.Key.ApplyPath(path.Value);}bulkPathFinderTask.Dispose();bulkPathFinderTask=null;}}else{if(singlePathFinderTask==null)return;if(singlePathFinderTask.Status==PathTaskStatus.Completed){agent.ApplyPath(singlePathFinderTask.Path);singlePathFinderTask.Dispose();singlePathFinderTask=null;}}}publicvoidSetPath(Vector2targetPoint,doubleaccuracy=1d){if(bulkPathFinderTask!=null){bulkPathFinderTask.Dispose();bulkPathFinderTask=null;}if(singlePathFinderTask!=null){singlePathFinderTask.Dispose();singlePathFinderTask=null;}foreach(variteminObjectGenerator.Instance.Agents){//stop moving!item.ApplyPath(newList<Cell>());}if(useBulkPathFinding){// generate dictionary (object,position)varobjectsStartPosition=ObjectGenerator.Instance.Agents.ToDictionary(agent =>agent, agent =>agent.Position);//finding pathbulkPathFinderTask=PathFinder.GetPathesAsync(objectsStartPosition,targetPoint);}else{singlePathFinderTask=PathFinder.GetPathAsync(agent.Position,targetPoint,accuracy);}}}