Point grid problem

Hi,

I am planning to convert our current path finding from PolyNav 2D Path Finding to A* Pathfinding project.

Our game is 2D isometric with freely sized objects (no tiles or fixed sized blocks). We currently automatically calculate PolygonColliders2D to objects where they hit the ground and I am using those points to create point graph.

It works ok, but there is one problem. Movement happens only from point to point. I would want it to be like in PolyNav, that if there is no collider between the current position and target position (raycast), then walk straight to target position. If there is something between, then calculate path finding route using points. I think point grid would suit my purpose best. At least I don’t want to use grid as it had to be pretty dense.

I don’t know how to do it. Is it possible?

Hi

The closest approximation to PolyNav in the A* Pathfinding Project is the navmesh graph or the recast graph.
Currently the recast graph cannot take 2D colliders into account however, and the navmesh graph would require you to model the navmesh by hand, which might not be feasible in your case.

I would have recommended the RaycastSimplifier component, but it seems I haven’t added 2D support to that yet in the current version.
I have fixed this now in my dev version, the updated scripts are here: https://pastebin.com/qwmk1Euw (RaycastModifier.cs) and here https://pastebin.com/vnmhGvDH (RaycastModifierEditor.cs).

With your current approach of using a point graph you can attach the (updated) RaycastSimplifier component to your AI gameObject (the same one with the Seeker component), enable raycasting and 2D physics and set the layer mask to the layers that your obstacle colliders are on.
This will produce a path that is shorter, but it may not be able to simplify it as much as can be done with a recast/navmesh graph or with PolyNav 2D.

Thank you very much. Great support you have!