Linking two graphs

Hi there!

Just implementing this into my 2D game.

The game is top down, and has multiple storeys laid out horizontally in the scene. So what I’m hoping is possible is to have a graph for each storey, and a way to specify links between graphs? I’ve got my multiple graphs setup, but I can’t seem to figure out if there’s a way to link the graphs.

I’m really sorry if this has been asked and answered, but I appear to lack the correct search terms to find it!

Sorry to bump this, but LayeredGraphs seem closer to what I’m after, however they seem to rely on things being properly layered. Where being 2D, I need to space my layers out across the scene.

Hi

This area of the package is unfortunately not that well documented. However you can use the NodeLink2 component to create off mesh links between different points on graphs. Unfortunately right now only the RichAI script has built-in support for automatically detecting these off mesh links, however that cannot be used for grid graphs. The AIPath script will just try to follow them as if they were part of the path, which may lead to strange behavior. So maybe you will have to make some modification to the movement script that you are using so that it can detect these links and teleport between them instead.

Thanks for the response. So are you saying I should implement NodeLink2s to create the links, but then detect them in my movement script? Or do they not work at all with grid graphs?

Worst case I could create my own floor change objects, and check the floor of the desired position then path from floor change to floor change until the AI is on the correct floor.

Hi

They work well with grid graphs, however the AIPath movement script doesn’t differentiate between those links and any other connection (e.g moving from one grid tile to the next). If they are stairs one easy solution is to place a trigger near the stair so that if an AI moves there it will be instantly teleported to the corresponding stair.

Alright, that makes sense and sounds perfect! I’ll need to do a similar thing for player controlled characters as well.

However I’m struggling to figure out how to actually implement a NodeLink2, haha. It doesn’t seem to be a MonoBehavior and I can’t find any documentation on how to implement one. I couldn’t find an example in the example scenes either, but it’s possible I may have missed it! Is there somewhere with a brief step-by-step guide for implementing it (and then potentially detecting when we’re at the point node)?

Hi

It is a MonoBehaviour. You can just drag it to a GameObject. If you search for it in the AddComponent menu I think it might be called Link2 instead of NodeLink2.
There is an example of it used in the second recast graph example scene.

Should NodeLink2 work with Point Graphs?

Can the agent move between graphs with precise attachments without using the NodeLink?