Follower Entity 2D Path calculation is really slow?

  • A* version: 5.4.7
  • Unity version: 2022.3.41f1

Hi there,

I am attempting to make some FollowEntities attack the player, but when I try to recalculate the path, the NPCs take quite a while to figure their paths out. Below is the code snippet. If I do not do the “SetPath(null)” stage, then instead of stopping (from the video), the NPCs continue where they were going until the path is recalculated for the same amount of time.

Is there a way to make this process faster?

I have attached a code snippet, video, & entity settings for context.

private void UpdateTarget(Transform location, bool updatePath = true)
    {
        if(destination.target != location)
            destination.target = location;

        if (updatePath)
        {
            followerEntity.SetPath(null);
            followerEntity.SearchPath();
        }
    }

Can you post your graph settings as well?

If your graph is very dense you may want to look into something like ProceduralGraphMover to have efficient pathfinding in a large scale world.