Hi Aron! So I jumped the gun and bought A8 Pathfinding on the Unity asset store and so far I really like what I see!! I have a beginner question for you…
So I’m using RichAI on a Recast graph and my question is regarding slowdownTime when used in conjunction with endReachedDistance. It seems that slowdownTime works well when the endReachDistance is very small (for example 0.1m) but when endReachedDistance is fairly large (for example 2 or 3m) it seems it’s not operative anymore.
In other words it would seem slowdownTime doesn’t take the position inferred by the stopping distance into account and instead is based entirely on the path’s destination (rather than the position at which the AI is actually going to stop due to endReachedDistance).
Is that by design, or am I doing something wrong? Is there a way to have the AI slow down when reaching the endReachedDistance?
That is by design at the moment, however it’s true that that might be something I should change.
Generally however if you want to stop the agent that far away from the target you should set the destination there instead. 2-3 meters is quite a lot. Is there a reason you cannot set the destination to the desired point directly?
Thanks for your quick reply! I do believe it would make sense to take the “stopping radius” around a destination into account, as currently it makes the system look like it’s not working as expected.
Now regarding your question I was simply trying to implement a “follow” behaviour by giving the target’s position to the AI and having it stop before it bumps into it (or pops on top of it).
Ah I see.
If you want that behavior you could open up the RichAI.cs script and find the line
var speedLimitFactor = distanceToEndOfPath < maxSpeed * slowdownTime ? Mathf.Sqrt(distanceToEndOfPath / (maxSpeed * slowdownTime)) : 1;
and then change that to
var speedLimitFactor = distanceToEndOfPath - endReachedDistance*0.9f < maxSpeed * slowdownTime ? Mathf.Sqrt(Mathf.Max(0.0f, (distanceToEndOfPath - endReachedDistance*0.9f) / (maxSpeed * slowdownTime))) : 1;
and I think it should work the way you want it to.
The 0.9 multiplier is just to make sure that the destination is seen as reached. If we didn’t use it the agent’s speed would approach zero as it approached the stopping radius.
Excellent! The variable speedLimitFactor in your snippet is called slowdownFactor in the script but it’s just a detail. Thank you very much!
Quick question though: Is that something I’ll have to replace manually when I update the asset from the asset store?
Ah. Yeah I might have renamed that recently.
This is unfortunately something you have to replace manually .
Using version control like git helps a lot though. You could just re-apply a commit every time (which would work most of time, except when too large things have changed).