Is there a way to know if FollowerEntity has an actual path to its target (i.e if the player is up on a rock, it pathed somewhere close by but there was no way for it to reach the player, is there a way that I can know that).
This isn’t checking if it HAS a path. When given the player’s destination, it’ll create a path to somewhere close by to the rock but won’t be able to actually reach the player. So it’ll still “have a path” even if the player can’t be reached.
My gut reaction was to take the end path position & distance check to the destination position and see if they’re within 0.5m but I don’t think that’s a very elegant solution. It seems like it might be a common want so I’m wondering if there’s a better way to go about it.
My reason:
If the player jumps up on a rock, enemies group up at the base of it & are easy for the player to defeat. I’d rather that enemies if they know they can’t reach the player just run around the area randomly (Making it hard for the player to use arrows on them).
I want to wrap this in a func like “CanReachDestination”. So I can easily go If(CanReachDestination()) …
I think this is the right solution, though maybe use the agent radius and stop distance if you want it more precise for various FollowerEntity settings. That way a big agent that stops further away to attack can still reach the player when smaller ones can’t.
Yeah I was gonna suggest the same too- checking the distance from the last node. But I also went and read up on the documentation because I swore I’d seen something pretty related to this before-- and I have!
You can use Path.PathCompleteState to see if we actually got to the target node. I think there’s an important caveat there though- if you’re using a sparsely detailed graph, that node may not be the direct position of the player I believe. Honestly don’t take that as gospel though because I may be wrong there.
Regardless let us know if either of these two options help!
The PathCompleteState won’t actually give you the info you are looking for. PathCompleteState.Partial will only be set if the Path.calculatePartial setting is enabled (default disabled) and the path could not reach what it thought was the closest reachable node. This can happen due to ITraversalProviders or tag settings.
Instead, I would actually suggest using FollowerEntity.endOfPath to see if this is indeed within your required distance.
If you want, you can do a AstarPath.GetNearest query on your actual destination to see if there is a closer node available.