Nodelink2 pathfinding tag not working with FollowerEntity

Hello!

Unfortunately, I don’t think Nodelink2 pathfinding tags work correctly with FollowerEntity. I have a nodelink2 between land and sea, and I want some characters to enter the sea and others not to. I’ve got an agent which can traverse land but not sea (done this by setting the pathfinding → traversable graphs) and also I’ve modified the agent tags so that the sea link (which the nodelink2 is assigned) is disabled for said agent. However, when the agent is chasing me, and I run into the sea, they follow me into the sea still by using the nodelink2. Please can you assist, many thanks.

Dom

Hi

I cannot replicate this. In the RecastOffMeshLinks scene I configured a link to use Tag 2, and the FollowerEntity to not be able to traverse Tag 2. This works just as expected. Can you replicate it in that scene?

Note that “Traversable Graphs”, in contrast to tags, only applies when searching for the start and end nodes of the path. So it is valid for it to start on a “valid” graph, move to an invalid graph, and then back again, within a single path.

Hi Aron,

Thank you for your response. I was able to get it working as intended within the example scene, so I’m unsure why it’s not working for my project! There’s a few things in my project which I guess could potentially lead to problems, but I haven’t had a chance to investigate them all yet:

  1. Sea and land are different recast graphs. I do this because the sea is just a basic plane, and doesn’t require anywhere near the precision that the land graphs have. This could potentially be the issue? I modified the example scene so that the drop/jump links connected to two different graphs, and it exhibited slightly different behaviour. It seems to not recognise the link, and just ran to the edge of the roof. Did I do something wrong? In my scene, the FollowerEntity definitely still uses the nodelink2, as you can see it clearly running from one end to the other.
  2. I cache graph data, but presumably that wouldn’t be it? I tried regenerating the cache, no change.
  3. We don’t automatically recalc paths, I don’t think this would lead to issues but just thinking of anything I do differently in my project. To try and maximise performance, and because we don’t need recalcs/local avoidance, paths are only calculated when the destination changes.

Can’t think of anything else that might be causing the issues right now. The use of two different graphs could be the issue(?) but I don’t know whether I did it correctly in the example scene and need to play further.

Okay latest findings, I did some debugging, and I’ve found the cause, but not found why it’s happening yet. I looked at the enabledTags field in the Path class, and it’s set to -1, despite that not being the case in my inspector. I manually set it to 1 during debugging, and it produced the expected “Searched all reachable nodes, but could not find target”

I’ve debugged a little more, seems as though the useSettings() method isn’t being called.

I think it’s because we’re doing things a little more manually in my game (check point 3 in my concerns list above).

image

I’ll try calling the method manually, but is there a recommended approach for cases when we are doing manual calculations rather than auto path recalcs? Thanks!

I’ve been able to fix by enabling path recalcs, but ideally, calling SearchPath myself would be ideal. There’s two problems that I currently face:

  1. There’s no “OnDestinationReached” event for FollowerEntity that I can register too, as far as I’m aware(?) So, I cannot disable path recalcs once destination has been reached. I’d be fine with enabling AutoRecalc every time I want the agent to move, and just have a long 10 second recalc period for better performance, but certainly don’t want it calculating paths when we’re at the destination, so being able to disable once reached would be good.
  2. Is there any sort of “OnError” event that I can register to? If the agent cannot reach the sea due to the nodelink2 tag, I’d rather just cancel the path search, rather than have it spam the error message because it’s constantly retrying.

Thanks for any guidance you can provide!

You can check the ai.reachedDestination boolean.

Right now, no. But I’m thinking about solutions for this.

Hi Aron,

Thanks for your response.

Regarding ai.reachedDestination Is it possible to get a OnReachedDestination event for FollowerEntity please, or is it not possible? I presume raising an event might be more performant than checking the bool every frame, but I don’t know about ECS, hence my question :slight_smile: I recall reading in your docs that polling for information on the FollowerEntity every frame can be slow because of the way ECS works? I’ve avoided doing so.

Regarding the nodelink2 error, is there a recommended way of handling this for the time being? :slight_smile:

Also, is it possible to have ai.SearchPath modified in a future update so that the agent’s settings are correctly applied to the internal path that’s created? This has been the cause of my issues, so if it’s a bug it’d be nice to get it fixed. Or is there a reason that the path created using SearchPath doesn’t have agent settings applied? If changed, I’ll be able to avoid using path recalcs.

Indeed, that was a bug. Sorry about that. I have fixed it locally, and a fix will be included in the next update.

It’s quite tricky to send an event in a performant way using ECS. I have also wanted to avoid the OnReachedDestination event because it has a lot of footguns (e.g. what if the destination is only moved 1 cm, will it trigger again?).
Unless you have hundreds of agents, polling the followerEntity.reachedDestination property shouldn’t be a problem at all.

Brilliant, thanks for fixing the bug!

As for the event, not to worry, I thought it’d have some sort of caveat related to ECS, but worth asking anyway. Least I now know :slight_smile:

Sorry to pester, but is there any last thoughts on how I can handle the nodelink2 error when calling SearchPath? Final query of mine and then I’m all good to go!

You mean that it constantly retries?
Currently, I cannot see an easy way to handle this in the current version, I’m afraid.

Sorry I more meant, how do I know when it’s hit this error? I want to know this so I can then try and handle it by cancelling the path search :slight_smile:

Hi Aron, could I please ask whether the patch will be released soon? Eager to test with it :smiley: Thanks!