ST2U2DNavMeshImporter is a Unity Package that provides a custom importer to automatically setting up 2D Navmeshes (using NavMeshSurface2DBaker) when importing Tiled tilempas through SuperTiled2Unity.
The importer automatically creates a NavMeshSurface with the correct position, rotation, size and all the necessary components.
All that’s left to bake your NavMesh after importing the tilemap is the press of a button!
- In Unity, go to your tilemap and set Custom Importer to CustomImporter_2DNavMesh. Alternatively, if you want to generate NavMeshes for all your tilemaps, uncomment the [AutoCustomTmxImporter] attribute in CustomImporter_2DNavMesh.cs
- On the ST2U Settings object, press the “Reimport Tiled Assets”-Button.
- In the scene where your tiled map is being used, search the tilemap object for a “NavMesh” child and select it.
- On this child, there’s a Surface2DBaker component. Press the “Bake 2D”-button on this script to generate the NavMesh.
What collider types are being supported?
- TilemapCollider2D (For those to work, you have to make them part of a CompositeCollider2D, though!)
Baking takes a really long time, even for a small map, why is that?
Your NavMeshAgent radius is probably way too small. Experiment with the radius until you find a radius that’s as big as possible while still giving you accurate results.
The resulting mesh is very inaccurate, why is that?
Your NavMeshAgent radius is probably too big. Experiment with the radius until you find a radius that’s as big as possible while still giving you accurate results.
Is there a way so I don’t have to press the bake button?
Not at this moment, unfortunately. At the moment I don’t see a clear solution for this which I could implement in a clean and simple manner. Figuring this out would probably take some time I’d rather spend on other projects as long as there’s no need for it. But let me know if that’s a must have feature for you and I’ll see what I can do!
Current version tested with:
- Unity 2018.3.0f2
- SuperTiled2Unity 1.1.9
- Unity NavMeshComponents 2018.3.0f2