Navmesh for 2D, Divide by Zero


I am trying to create a navmesh for a 2D game and I get a division by zero error because depth is 0 and my scene is flat…

How would i fix this?

Edit: I got it to somewhat work by changing the rotation to -90 and moving the number in size.y to size.z…
I am getting another problem where the mesh generated doesnt fill the whole box… just the half.

Edit1: Fixed it by setting the size of Y to 1…
Cant figure out how to get it to see the colliders though.



Even if your scene is flat I recommend that you use a small positive size anyway as 2D colliders are still positioned in 3D.
Even if you positioned them at Z=0 they might or might not be included depending on floating point errors.


I also have Polygon Collider 2D which isnt being detected by the raycast generator


The recast graph has no support for 2D colliders at the moment. It supports regular MeshFilters and 3D colliders.
Maybe you want to use a grid graph instead?


That sucks :confused:
I didn’t want to use grid graph because I didn’t like the zig-zag movement I would get when an object moves from point A to B

Thanks though.


You can use e.g a Raycast Modifier, Funnel Modifier or the Simple Smooth modifier to get rid of that zig-zag movement.

See also


Thanks! thats just what I needed.