Unexpected Sideways Sliding of agent Using FollowerEntity on Recast Graph

I’m using v.5.0.6 on Unity 2022.3.21f1.

The agent (a car) starts on a racetrack, which is configured with a Recast graph. The agent is using FollowerEntity and AIDestinationSetter. The Target of the AIDestinationSetter is set when the scene loads and is not changed at all. Additionally, all other GameObjects in the scene are stationary (for testing purposes) and are correctly detected as unwalkable by the Scan process.

The length of the racetrack is 3,000m (world units). I have set the “Movement Debug Rendering” to “Path”, and I can see that a path is always available.

With the FollowerEntity - “Recalculate Paths Automatically” set to “Dynamic” and the “Maximum Period” set to the default 2s, in every run, the agent follows the path quite well, but at about 2,000m, it slides from the middle of the track to the left side, apparently with 0 speed in the direction of the path, for about 1 second. When I pause play and move frame by frame, the agent goes forwards & backwards 0.5m for about 30-40 frames and then continues normally until the destination is reached.

Even though I could see from the debug rendering of the path that a path was available at all times, I suspected that, for some reason, a path wasn’t available momentarily causing the issue.

So, I made some tests with the “Maximum Period” set to 1s and 0.5s, and the “sliding” seemed to become less and less. So, I set the “Maximum Period” to 0s, and the sliding disappeared, and the problem was fixed.

However, it doesn’t seem right to set the “Maximum Period” to 0s, especially since the destination doesn’t change, there are only 3 stationary obstacles before the destination is reached, and there’s no other action taking place.

I have attached some screenshots to show the problem:

  1. Correct movement of agent in the middle of the track:

  2. Sudden sliding movement to the left:
    Debug 5

  3. The agent getting stuck for 30-40 frames moving forwards & backwards 0.5m:
    Debug 6

  4. Agent continues to its path:
    Debug 8

Is there a workaround for this?

Thank you in advance.

Do you have a video of this happening?

While recording the video I noticed that the amount of sliding depends on the load. So I recorded 2 videos to show the difference:

Using Thread Count One - Sliding at about 4s

Using Thread Count Auto Low - Sliding at about 5s

I do my testing using a Thread Count of One. When I took the screenshots that I uploaded before, the sliding was more severe, apparently due to more load on my PC at that time.

EDIT: Even with Thread Count Auto High (16 threads on my PC) there’s some sliding, but the FPS drops to about 40.

@aron_granberg have you seen the videos?

Hi

Would you mind setting A* Inspector → Settings → Graph Coloring to NavmeshBorderObstacles and send a new screenshot?

  1. Moving normally along the path - the last step (frame?) before sliding

  2. 34 steps after sliding started - the steps followed the pattern 1 step forward & 1 step left

  3. 1-2 steps after the end of sliding (item ‘2’ above) - the agent went past the edge of the graph

  4. 56 steps after the end of sliding (item ‘2’ above) - the agent continued moving normally. During these 56 steps it followed the pattern 1 step forward & 1 back along its z-axis

Strange. It wasn’t what I expected.

Would it be possible for you to share your project with me, so that I could take a look?

My project is quite large. I’ll try to scale it down as much as I can, while still being able to reproduce the issue. This might take a while, so, I’ll let you know when it’s ready.

I sent you a message with the download link.

Hi @aron_granberg do you have an update on this?

Hi

I haven’t had time to look at it yet, I’m afraid. I can’t promise I’ll be able to look at it soon either, as I’ll be doing an eye operation tomorrow, and might be out of comission for a few days. But I’ll check it out as soon as I can.

1 Like

Hi,

No, problem. I still have over a month before releasing this game.

I wish you all the best with your eye operation!

1 Like