Hello, I have been using the A* Pathfinding project for almost a year now, specifically the FollowerEntity script on a Recast Graph, to control my units in a 2D RTS game. However, the problem that I’ve been facing constantly is my units slowly but noticeably drifting upwards whenever they should be stopped. Here’s a link to show what’s happening.
I’ve created a fresh new project to try to figure out what’s been causing this, disabled gravity, and the units only ever stop drifting upwards if I call followerEntity.canMove = false. However, I do need them to be able to get pushed around by other units, so this is not a solution for me.
From what I’ve read on the forum, I’m guessing this small increase in speed varying from 0.01-0.03 is from floating point precision errors? If this is the case, is there a way for me to account for those precision errors somewhere in the FollowerEntity script, like adding an if statement checking if reachedEndOfPath or reachedDestination is true, and then setting the velocity/desiredVelocity manually to 0?
Thanks in advance!
Hi
I’m not quite sure what’s going on.
To start with, can you try:
- Change all rotation speeds to “infinity” instead of just a very high value. This can make it more stable potentially.
- Try to set position and rotation smoothing to zero.
Let me know if that improves anything.
I’ve tried what you asked, however for some reason, setting the rotationSpeed value to infinity completely broke the pathfinding? After setting it to infinity I could no longer make the unit head to the destination, even though the unit’s destination, remaining distance is changed. Also, the problem stays unless I remove the FollowerEntity component and re-add it completely fresh. Here’s another link.
Thanks. Looks like I introduced a bug at some time. I have fixed it locally, and in the next update an infinite rotation speed should work.
Just set it to a high value for now.
Thanks for your help. I’ve become a bit suspicious and decided to investigate further, since in the test scene for Recast2D the AI works perfectly, meanwhile on another scene it doesn’t.
Turns out it has something to do with the position of the FollowerEntity object on the Recast2D graph, since I managed to recreate the ‘drifting upwards’ in the test scene provided in the samples, by simply moving the graph and the AI GameObject by ~+40.5 on the Y coordinate.
Here’s another link showcasing it in action. Pay attention to the speed of the FollowerEntity component and the transform position as soon as I move the object above Y40.5.
Hi
Which version of the package are you on?
Thanks for responding.
The newest version available that is not the beta, version 5.3.8.

Thanks.
I have tried, but have not managed to replicate this issue.
Can you replicate it in one of the example scenes? Or can you provide step by step instructions for how to replicate the issue?
Thanks!
I managed to replicate it. It was due to a tiiny floating point error resulting from the way quaternions are represented. I changed the relevant code out for a more numerically robust variant, and now I cannot replicate it anymore.
The fix will be included in the next beta version update.
1 Like