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.
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.
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:
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.
I cache graph data, but presumably that wouldn’t be it? I tried regenerating the cache, no change.
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).
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:
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.
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.
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 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?
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.
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
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!