SetNet.PathFinding
1.3.2
dotnet add package SetNet.PathFinding --version 1.3.2
NuGet\Install-Package SetNet.PathFinding -Version 1.3.2
<PackageReference Include="SetNet.PathFinding" Version="1.3.2" />
<PackageVersion Include="SetNet.PathFinding" Version="1.3.2" />
<PackageReference Include="SetNet.PathFinding" />
paket add SetNet.PathFinding --version 1.3.2
#r "nuget: SetNet.PathFinding, 1.3.2"
#:package SetNet.PathFinding@1.3.2
#addin nuget:?package=SetNet.PathFinding&version=1.3.2
#tool nuget:?package=SetNet.PathFinding&version=1.3.2
SetNet.PathFinding
Pathfinding + path-following for SetNet, over SetNet.GeoData.
Find a route, then walk an entity along it — server-side and engine-agnostic. One interface, IPathfinder, with the
right algorithm picked from the geometry kind:
- grid → A* (8-connected, octile, no corner-cutting) + straight-line smoothing
- multi-storey grid → A* over per-cell height layers (climbs stairs / crosses bridges between floors) + smoothing
- nav-mesh → A* over triangles + portal path + straight-line smoothing
IGeoData geo = GeoDataFile.LoadFromFile("world.geo");
IPathfinder finder = Pathfinding.For(geo); // grid or nav-mesh — automatic
Path path = finder.FindPath(mobPos, playerPos);
if (!path.IsEmpty)
{
var follower = new PathFollower(path);
// each server tick:
mobPos = follower.Step(mobPos, speed * dtSeconds); // moves toward the next waypoint
if (follower.Arrived) { /* reached the goal */ }
}
Built for scale (path everyone, every tick)
In an MMO every character and mob may re-path several times a second, so the hot path is allocation-free after
warm-up. A pathfinder instance is meant to be built once and reused (that's exactly how SetNet.Mobs holds it):
- Per-query working memory (
g/came/closed sets, the open heap) is pooled and reused across calls — nothing is allocated perFindPathonce the pool is warm. - Visited nodes are generation-stamped instead of cleared, so a query costs O(nodes actually expanded), not O(map size) — a short path on a huge map stays cheap.
- The pool is thread-safe, so one pathfinder can serve many agents from parallel AI ticks.
MaxExpansions(onGridPathfinder/LayeredGridPathfinder) caps the worst case: an unreachable goal returnsPath.Emptyinstead of scanning the whole reachable area.
var finder = Pathfinding.For(geo); // build ONCE, keep it
// ...thousands of times, from any thread:
var path = finder.FindPath(a, b); // no per-call array allocation
The World example (dotnet run --project examples/World -- bench) reports throughput on a reused instance.
Notes
- Server-side, no wire protocol. Movement is server-authoritative; clients see replicated positions.
PathFolloweris what SetNet.Mobs uses to turn aMoveTointent into authoritative motion — but Mobs treats the pathfinder as an optional seam (straight-line fallback when noIGeoDatais provided).- Nav-mesh routing uses a portal-midpoint path with line-of-walk smoothing (a robust stand-in for a full funnel).
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- SetNet.GeoData (>= 1.2.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SetNet.PathFinding:
| Package | Downloads |
|---|---|
|
SetNet.Locomotion
A unified server-side movement simulator for SetNet: one system advances the position of everything that moves (players, mobs, NPCs, projectiles) along pathfound routes at a fixed rate — with automatic subscription (create a Mover and it's already ticking). It replicates NOTHING: you read positions and replicate them your own way, and a Started hook fires when a mover gets a new destination so you can send just the point to clients (L2-style, client re-paths locally). Depends on SetNet + SetNet.GeoData + SetNet.PathFinding. |
|
|
SetNet.Mobs
Server-authoritative hostile AI entities for SetNet. One IMobBrain per mob type (aggressive, passive-retaliate, ranged/kiting, caster) — or compose one from behaviour components — behind a uniform tick loop that handles perception, threat, movement (via SetNet.PathFinding, straight-line fallback), ability cooldowns/casts/telegraphs, damage, death and respawn. Replication is a seam (IMobReplication, no-op default; poll MobServer.Mobs or handle MobMoved) — a StateSync adapter ships separately as SetNet.Mobs.StateSync. server.UseMobs() + client.UseMobs(). Rides the unified SetNet.Protocol on the Channels.Mobs channel. Depends on SetNet + SetNet.GeoData + SetNet.PathFinding (NOT StateSync). |
GitHub repositories
This package is not used by any popular GitHub repositories.