FollowerEntity randomly rotates/jitters on the spot

  • A* version: 5.3.3
  • Unity version: 2022.3.40f1

FollowerEntity pathfinding is behaving very inconsistently for us. Most of the time it works fine, but there’s seemingly random times (i’d say about 5-10% of the time?) when the agent suddenly does a little twirl on the spot. It happens mostly on corners (as seen in the gif) but sometimes also on when it’s moving in a straight line.

See example here: https://www.dropbox.com/scl/fi/iknanbfupw8wpe72o1zpq/pathfinding.gif?rlkey=kw80jy1g9jyomslrkr1as70dn&dl=1

We’re using a Grid Graph, which is static when these agents start moving about. Their destination is assigned once and doesn’t change until the agent has made it to its destination, there’s no local avoidance either so it’s fair to assume that it calculates a path and then stays on that path until it makes it there.

Here’s the settings I’m using:


To set the path, i use the following code:

_followerEntity.destination = target;
_followerEntity.SearchPath();

Things I’ve tried so far:
Messing with FollowerEntity radius, desiredwalldistance, stop distance, lead in radius, allow rotating on the spot, wall distance.
And on the grid graph: Cut Corners on/off, Changing the Collision testing Diameter.

The only thing that gave a noticeable improvement in the pathfinding was settings the thread count to “automatic high load”. That reduced the stuttering at least. Anyone got any ideas?

Can you record a gif of them walking along their path but with the gizmo showing their path visible?

Here’s a video with the Movement Debug Rendering set to Path.I tried reproducing this with only 1 agent walking but after an hour I had not come across it once. Only difference here is that I disabled the animations to reduce clutter.

https://www.dropbox.com/scl/fi/zdwvwzndy7wwy34xwuk5h/jiggle.mp4?rlkey=nqqgs5hrd41vuy0dxpkwydf13&dl=0

There’s 2 inconsistencies to be seen:

At the bottom of the screen, all the agents walk to the same spot (the middel of the blue circle) first, after that the next point is set (to the right, through the maze). Some of the agents walk in a nice curve, some start their curve and then halfway through it go straight for the next target and some do a jiggle there. EDIT: I guess this can be attributed to the path not being calculated yet sometimes.

At 0:23 you can see the first jiggle just top right of the red square.

I couldn’t get a capture of it now, but they also generally mess up just in front of the red object while moving up.

Another note: if I use AIPath instead of FollowerEntity it works just fine. Exact same test case, exact same code & parameters used (where applicable).

Hmm, pretty difficult one-- I’ve been bouncing back and forth between the video and Unity. Can you disable ‘Allow Rotating On The Spot’? Not sure if that’ll give you the moment you want but I’d like to see if that stops the spinning first.

That was one of the things I tried initially and did not fix it unfortunately.

I’ve gone back to AIPath for now because we’re on a bit of a deadline this week, with the Simple Smooth & Funnel modifiers it’s somewhat close to FollowerEntity (although FollowerEntity creates nicer looking paths imo). I’m not strapped for performance (yet) so I’m content leaving it as-is for now, but I’d love to swap back to FollowerEntity to free up the performance before we ship.

Not a problem :slight_smile: When you’re ready to try FollowerEntity again just let us know :+1:

Hey, I’m currently having the exact same problem with FollowerEntity. I’m using Unity 6000.0.42f1 and also A* 5.3.3.

Is there anything I can try to solve the issue?

Hmmm, go ahead and post your agent settings and I’ll see if I can find something :+1:

Thanks, here are my settings:

I’m also using this code to set the path:

 ai.destination = position;
 ai.SearchPath();
1 Like

Can you check this video that OP posted and let me know if the rotating/jittering issue you’re having looks the same as this?

I’m trying to find something that could be causing it but between default, OPs settings and yours I’m not seeing anything concrete.

Yes, it looks similar. I’ve just recorded a video where I’ve been able to show an extreme case:

After circling for 15 seconds he just continued to walk to the destination normally. In this video, Local Avoidance was disabled, so these were the settings:

In both examples I get the vibes that your agents are all trying to “circle back to a missed point”- and I would’ve thought that increasing the agent radius more would help? but @Aceria says he tried that so I’m not so certain. Can you both try a 1 meter radius if you haven’t already? And Aceria if you have already let me know?

Thanks for the reply. I’ve now increased the radius from 0.3 to 1, but this unfortunately didn’t solve it.

Can you drop a link to maybe a stripped down version of your project/recreated version so I can test this out and see if I find anything?

It’s a large project, but I can try to create a small project with the bug.

I’ve currently noticed, that the problem seems to get worse with a higher Time.timeScale. Maybe that helps already with replicating it.

Interesting note :thinking: Yeah do what you can to try and get that over and I’ll see what I can dig up. If Aron needs to get involved on this it’ll be helpful to have all that information regardless :+1:

I’ve just send you a DM with an example project where it can clearly be replicated. The problem is really the time scale. With a time scale of 1, it works fine, but if it is increased, the problem occurs.

I hope that will help to fix it. If you need any more information, just let me know :slight_smile:

Just wanted to check in and see if you had a chance to look at the project I sent. Let me know if there’s anything else I can provide to help :slight_smile:

Hey there, so I was waiting hoping OP would be able to rejoin the conversation so I hadn’t looked at it yet. But I just took a look and I did some tinkering around— I immediately noticed that the node size was rather tiny so I messed around with that with the time scale demo and… it looks better to me?

Can you try that and see if you’re seeing it the same way I am? There’s a very solid chance that I’m just looking “for the wrong things” since I’ve spent less time with it than you two, but their movements are a LOT cleaner with bigger node sizes in my testing even when I change it during runtime.