# Waypoint System with Point Graph and Recast Graph?

Hi,

I have an agent that needs to move along a set of nodes, like waypoints, to a destination. However I want my agent to have the ability to ‘detach’ itself from these waypoints and freely move along a navmesh if it meets certain criteria. For example, I need the agent to move along these waypoints for as long as possible, like a road, but once it gets close to its destination, it should be able to move like its on a navmesh so it can get directly to its target.

Furthermore, certain areas of the world, such as grass fields, should only have navmeshes, so my agent should be able to freely traverse them.

For the waypoint system, I am using a point graph because I’d like to take advantage of the ease of using it, and I need to use penalties based on connections so the agent can’t traverse in certain directions.

Is it possible to achieve something like this inherently through this asset? Can I use a point graph in this case or must I solely use a recast graph / navmesh and create a custom waypoint system? In the case of the latter, can I still use node connections to determine costs for traveling a certain way?

Edit:

To further clarify what I am looking for, please see this video of the game Emergency 4. https://youtu.be/_BJQTw1UJ3c

As you can see, the vehicle moves freely on a navmesh but switches to following waypoints based on the target destination’s distance. I know that I can create something like this myself, but is it possible to do so using point graph?

Hey,

This is definitely not an out of the box solution.

Aron might have a better solution but here is how I would do this with my current knowledge of the project.

I would make 2 graphs, a point graph only roads, and any other type of graphs for the free roaming.

On the Agent I would dynamically modify the graphs that the agent is allowed to traverse based on your desired criteria.

I’m not sure if this is a good approach in terms of optimization within a*.

• Toasty
1 Like

Thank you for your response. How can I choose which graphs the agent can traverse on? I was also thinking: if I can create points at runtime, then maybe I can just do that depending on certain criteria and it will give me a similar effect?

In my case, I’ll have a predetermined list of points, which are my road nodes, and if the target destination is close I’ll generate a new point with a much lower cost that my agent could take? Do you think that could work?

EDIT:
Okay so I tried doing this and I have run into an issue. It works the way I expect it to the first time; however, any other time after that it seems to run into some problems.

The first time, I can click pretty far away from the agent and it will follow the waypoints (the road) as expected. Then, if I click closer to it, it seems to move like its on a navmesh. After that though, the agent cannot pathfind further away because I am assuming there is no connection drawn between whatever new node the agent is at and the main road.

I can try fixing that myself, but I began to notice that every new path that is created doesn’t delete the connections of the old path. I tried removing the connection but it doesn’t seem to do anything.