Pathfinding framework
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.
.github
Data
Plugins
Source
.gitignore
ATTRIBUTION
AppData.dat
DefaultUserData.dat
Duality.dll
DualityEditor.exe
DualityEditor.exe.config
DualityPrimitives.dll
FarseerDuality.dll
LICENSE
NVorbis.dll
NuGet.Core.dll
OpenTK.dll
OpenTK.dll.config
PackageConfig.xml
README.md
UserData.dat
VistaBridgeLibrary.dll
Windows7.DesktopIntegration.dll
appveyor.yml

README.md

Pathfindax

Pathfindax is a pathfinding framework that can be used to get a path to a destination in a network of nodes. Currently A*, potential fields and flowfield are implemented. These implementations support the following features:

  • Support for up to 32 collision layers
  • Support for multiple agent sizes
  • Support for movement costs
  • Support for the duality game engine and the tilemap plugin through the Duality.Plugins.Pathfindax.core and Duality.Plugins.Pathfindax.Tilemaps.core nuget packages

Some examples of what pathfindax can do:

Getting Started

Installing

Pathfindax can be installed through the nuget packages which you can find at the bottom of this readme. When using duality there are also some extra packages you can install to make it easier to use pathfindax in duality. If you just want to use pathfindax you only have to install the Pathfindax nuget package.

For more info on how to install nuget packages see this. For more info on how to install duality packages see this.

A Simple example

The following example will show you how to create a nodegrid and find a path through it:

//Setup the nodegrid and pathfinder.
var pathfindaxManager = new PathfindaxManager();
var factory = new DefinitionNodeGridFactory();
var nodeGrid = factory.GeneratePreFilledArray(GenerateNodeGridConnections.All, 3, 3);
var nodeNetwork = new DefinitionNodeGrid(nodeGrid, new Vector2(1, 1));
var pathfinder = pathfindaxManager.CreateAstarPathfinder(nodeNetwork, new ManhattanDistance());

//Request a path.
var pathRequest = pathfinder.RequestPath(nodeNetwork.NodeGrid.ToIndex(0, 0), nodeNetwork.NodeGrid.ToIndex(2, 0));
Console.WriteLine($"Solving path from {pathRequest.PathStart} to {pathRequest.PathEnd}...");

//Poll the status to check when the pathfinder is finished.
while (pathRequest.Status == PathRequestStatus.Solving) { }
switch (pathRequest.Status)
{
	case PathRequestStatus.Solved:
		Console.WriteLine($"Solved path! {pathRequest.CompletedPath}");
		break;
	case PathRequestStatus.NoPathFound:
		Console.WriteLine("Could not find a path");
		break;
}
Console.ReadKey();

More examples can be found here.

Pathfindax inside duality

The duality packages make it easier to use pathfindax by abstracting most of the boilerplate code you see in the example above. A tutorial covering how to use pathfindax in duality can be found here. Additionally some example components can be found here.

Other

Build status:

Branch Status
master Build status
develop Build status

Nuget

Library Version
Pathfindax NuGet Badge
Duality.Plugins.Pathfindax.core NuGet Badge
Duality.Plugins.Pathfindax.Tilemaps.core NuGet Badge