Robmaister / SharpNav

Advanced Pathfinding for C#
sharpnav.com
Other
537 stars 129 forks source link

2D Settings definition #22

Closed keslabs closed 9 years ago

keslabs commented 9 years ago

I've just started with SharpNav and hit either a misconfiguration or issue.

I've got a 2D map consisting of 2400+ triangles after conversion to SharpNav. The bounding area for it is { Min : (-100, -100, -100), Max : (169732.2, 144519.6, 101) }.

When I attempt to generate the navigation mesh, the PolyMesh doesn't have any polygons or vertices. I'm not really certain of the best way to determine the settings I should use or how to properly implement SharpNav for only a 2D environment.

Could you provide some insight into both properly implementing SharpNav for 2D environments as well as how to deal with different units of measure with the settings?

BTW, Thanks for providing such an awesome project. I'm extremely excited to get going with it.

keslabs commented 9 years ago

Resolved through experimentation.

Robmaister commented 9 years ago

If this was brought about by confusion or lack of clarity somewhere in the API, please share what went wrong so that I can clean it up before a 1.0 release.

Robmaister commented 9 years ago

Also SharpNav will probably be a bit overkill/inefficient for pure 2d environments. You can change the units/scaling for everything by creating a new NavMeshGenerationSettings class. Right now there's only one preset group of settings, NavMeshGenerationSettings.Default, which provides settings for an average-sized human in a space where 1 unit = 1 meter. This will generally line up with the units that most physics engines work in.

If there are other common spaces/units that people work in, I can create additional presets in the class. SharpNav should work fine in most spaces, unless your units are massive or tiny (floating point errors/inaccuracies). All the classes in the generation process should have a constructor that accepts a NavMeshGenerationSettings instance.