Skip to content

Repository files navigation

PathFindingProject

This is my diploma work

About

  • 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.

Wiki

Installing with Unity Package Manager

(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.

Installing without Unity Package Manager

Or you can just copy the folder 'Runtime' in your asset scripts folder.

How to use

//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);}}}

About

Unity3d multithread pathfinding project with non-linear grid

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages