Generating Jump Graph for navmesh

I need a jump-graph for jumping characters on a navmesh.
Unity navmesh has failed me, and i couldn’t find any implementation here neither.
So i think i’ll post as i go, and see how far i can get.

Got detecting external edges on navmesh

Raycasting for drops!
image

Applying some raycasting and logic. Blue for vertical, red for horizontal.

Now i just need to figure out how create links in a graph without NodeLink2 objects. Don’t want to slow down my scene with 1000s of objects.

Also i might need to timeslice the recast graph generation, and update tiles one by one in editor frame update, cause it’s gettign annoying that i can’t work while navmesh is being regenerated.

Hmm, i can’t find any RemoveNode or Clear functions for graphs.
//found it - ((IGraphInternals)jumpGraph).DestroyAllNodes();

When i try to add node to point graph i get this exception.

Exception: Trying to initialize a node when it is not safe to initialize any nodes. Must be done during a graph update. See http://arongranberg.com/astar/docs/graph-updates.php#direct
Pathfinding.PathProcessor.InitializeNode (Pathfinding.GraphNode node) (at Assets/Thirdparty/AstarPathfindingProject/Core/Misc/PathProcessor.cs:252)
AstarPath.InitializeNode (Pathfinding.GraphNode node) (at Assets/Thirdparty/AstarPathfindingProject/Core/AstarPath.cs:1505)
Pathfinding.GraphNode…ctor (AstarPath astar) (at Assets/Thirdparty/AstarPathfindingProject/Core/Nodes/GraphNode.cs:98)
Pathfinding.PointNode…ctor (AstarPath astar) (at Assets/Thirdparty/AstarPathfindingProject/Generators/NodeClasses/PointNode.cs:45)
Pathfinding.PointGraph.AddNode (Pathfinding.Int3 position) (at Assets/Thirdparty/AstarPathfindingProject/Generators/PointGenerator.cs:274)
NavmeshJumpGenerator.AddLink (UnityEngine.Vector3 start, UnityEngine.Vector3 end, System.Single costFactor) (at Assets/platformController/scripts/gameplay/navigation/NavmeshJumpGenerator.cs:260)
NavmeshJumpGenerator.JumpsFromEdge (UnityEngine.Vector3 v1, UnityEngine.Vector3 v2, System.Boolean addLinks) (at Assets/platformController/scripts/gameplay/navigation/NavmeshJumpGenerator.cs:187)
NavmeshJumpGenerator.GenerateLinks () (at Assets/platformController/scripts/gameplay/navigation/NavmeshJumpGenerator.cs:250)
NavmeshJumpGeneratorEditor.OnInspectorGUI () (at Assets/platformController/scripts/gameplayEditor/NavmeshJumpGeneratorEditor.cs:20)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass58_0.b__0 () (at <68393a67c64944d5ac86cef5ce4f102f>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Ok, figured it out.
put the link generation into GraphModifier.OnPostScan

So Funnel cannot process PointNodes for some reason, it throws exception “Unsupported node type or null node”.
Had to modify funnel to traverse point nodes.

Anyway, got em auto jumps!

1 Like

Now just need to teach Ai to recognize the jump links and raycast-avoid dynamic obstacles.

You know what. I’m gonna remove this exception in PathProcessor.
Not sure why it’s needed. But without it i can trigger jump graph build any time i want in editor time. I’m not gonna rebuild it in playtime.

Also i had to modify the pathfinder a bit:


Also i removed all popups from pathfinder editor.
Really speeds up the workflow.

Sorry for the late response.
The proper way to do this is to call AstarPath.active.AddWorkItem(callback). I suppose outside game mode it doesn’t make a difference, but in play mode it ensures that no pathfinding is running at the same time as your code that modifies the graphs.