h8man / NavMeshPlus

Unity NavMesh 2D Pathfinding
MIT License
1.76k stars 205 forks source link

Navmesh Tilemap help wanted #195

Closed switchCTRL closed 2 months ago

switchCTRL commented 5 months ago

Hi! I've been trying to get NavMeshPlus to work with Tilemaps for some time now. Unfortunately, I'm encountering some difficulties. The mesh never looks as expected. I'm probably configuring something wrong.

My current setup is as follows: Let´s say I have a Grid with 2 rectangular Tilemaps:

Bildschirmfoto 2024-04-30 um 13 39 04 Bildschirmfoto 2024-04-30 um 13 41 00

My Tiles are custom rule tiles each with a custom physics body. I tried to set the Use Geometry to Colliders. Then I get this Mesh:

Bildschirmfoto 2024-04-30 um 13 45 19

If I set it to Render Meshes (which I think is not what I need because some tiles are "half" tiles) it looks like this:

Bildschirmfoto 2024-04-30 um 13 46 22

In both cases the agents can run through the cliff of Level 1 which should not be possible. Is there a way to get multiple tile map layers to work?

h8man commented 5 months ago

You have navmesh modifier + tilemap modifier, but you need only one of them

switchCTRL commented 5 months ago

Thanks for the response and sorry for my late answer. The NavMeshModifierTilemap has NavMeshModifier as requirement.

Bildschirmfoto 2024-05-03 um 09 18 16

If I use only the NavMeshModifier in combination with PhysicsColliders I get the result from the first screenshot. I assume one cannot have both, using physics shapes and define specific tiles as walkable, fast walkable, water etc.?

What I want to achieve is that the layers of my tile map are walkable on their own. If I connect them with stairs or something similar one can travel from on layer to another. Like in this picture:

Bildschirmfoto 2024-05-05 um 12 51 11

where

h8man commented 5 months ago

I'm very sorry, I check that from a code, and didn't notice modifier is used by builder. So yes, Navigation Modifier is required with Modifier Tilemap. Here is sample: https://github.com/h8man/RedHotSweetPepper/tree/master/Assets/Scenes/SampleSceneTilemapModifier

Try this scene to get a feel on how to works, as documentation is not updated right now

As for layers, Navigation doesn't support layers in traditional sense, cause everything is projected into 1 navigation mesh.