SharpNav
Robert Rouhani, Samuel Yuan,
RenJie Xie, Ryan Lin,
Dashiell Kieler
What is it?
SharpNav is a library with an editor, all written in C#
-
It generates navigation meshes
-
It finds paths through navigation meshes
-
It coordinates crowds navigating a mesh
- It integrates well with a lot of game engines
How do I use it?
- Provide high-detail geometry (a level in a game)
- Provide size of characters and units
- Receive a navigation mesh
Is it hard to use?
No.
//prepare the geometry from your mesh data
var tris = TriangleEnumerable.FromIndexedVertices( ... );
//use the default generation settings
var settings = NavMeshGenerationSettings.Default;
settings.AgentHeight = 1.7f;
settings.AgentWidth = 0.6f;
//generate the mesh
var navMesh = NavMesh.Generate(tris, settings);
What else does it do?
Finds paths
var navMeshQuery = new NavMeshQuery(navMesh, 2048);
Vector3 startPos = agent.Position;
int startRef = agent.NavPoly;
Vector3 ext = new Vector3(5, 5, 5);
Vector3 endPos = new Vector3(35.6f, 20.1f, 200f);
int endRef;
navMeshQuery.FindNearestPoly(ref endPos, ref ext, out endRef, out endPos);
var path = new List<int>();
navMeshQuery.FindPath(startRef, endRef, ref startPos, ref endPos, path);
(API still needs some work)
What else?
Manages crowds
var crowd = new Crowd(30, 0.5f, navMesh); //crowd with up to 30 agents
// ...
foreach (var agent in Agents)
crowd.AddAgent( ... );
// ... in game loop
crowd.Update(frameTime);
for (int i = 0; i < Agents.Count; i++)
Agents[i].Position = crowd.Agents[i].NPos;
(API also needs some work)
Editor
- Accepts various formats for input geometry
- Allows transforming objects
- Create off-mesh connections
- Save navigation mesh and project
Demo
Thanks
Professor Moorthy
Professor Goldschmidt
Sean O' Sullivan
RCOS
Questions?
SharpNav
By Robert Rouhani
SharpNav
- 1,761