EndReachedDistance in v3 vs v4

I upgraded from 3 to 4. Consequently, I’m finding that my ranged units are no longer stopping at the EndReachedDistance like they used to. Rather, the second they get within the EndReachedDistance, they call OnTargetReached() once, but continue to move towards the target. Once they get within “1” range, they start spamming OnTargetReached() every half second, all the while trying to hump the target.

I tried modifying the EndReachedDistance values for the “Procedural” example too but could not get the bot to stop moving to the actual point I clicked, either. Am I missing something glaringly obvious? Has the way this variable works been changed?

Or maybe it always worked this way, but for some reason, I lucked out completely in the previous version and configured it in a way that allowed me to use this variable to get my ranged units to stop X distance away from their target (?)

So, just to put it super simply:

Start a new project. Open up the procedural example scene. Select “Bot CharacterController” and modify EndReachedDistance to 3.

In 3.8.6: The bot will move towards the point you click, but will stop some distance before the point.
In 4.0.6: The bot will move to and stop at the point you click regardless to what you set EndReachedDistance to.

I can find no documentation about this change, what it means for my project, if it’s intended, etc. At this point I assume I should just switch back, or is there a preferred method for stopping a certain distance away from a target?


This was an intentional change, but I have to say I didn’t think about the case of using it for archer-like behavior and thus didn’t think it would be a very notable change.
In 3.x the AI could never reach the target that precisely, it would instantly stop when within the EndReachedDistance. Commonly this distance was set relatively low to make the character get very close to the target. In 4.0 the character will continue to move to reach the target point very precisely (if possible) which in most games is what you want.

Due to the archer use case I am thinking about introducing a new option which determines if the character should stop immediately when getting within EndReachedDistance from the target or if it should continue to move to the target.
In the mean time, adding this to a separate script should get you the behavior you want I think (I haven’t tested it myself):

AIPath ai;
void Awake () {
     ai = GetComponent<AIPath>();

void Update () {
     ai.canMove = !ai.TargetReached;

Ah, I see. Thank you, Aron. I suppose I never really dug into how other people were accomplishing things. I was even having my melee-type enemies stop at a short distance (within melee attack range) from the player, instead of having them bump into the player. Or if I wanted to have a unit interact with a tool, I’d do the same thing. I sort of thought this was the intended use this whole time! Oops.

Hmmm I don’t think this would work either since TargetReached is cleared every x milliseconds, when the path is searched again.
I tried it and that’s what happens, maybe I’m doing something wrong?

I think there might be a bug in some movement script in the current version that causes this to happen. However I am pretty sure I have fixed it in the current beta.