How to prevents changing the seeker's path?

  • A* version: [5.1.2]
  • Unity version: [2022.3.46f1]

When I drag an object and this object will UpdateGraph continuously, for enemies (containing seeker components) that have been spawned, the path will not change, but for enemies that have just spawned, the path will be changed.
How do I prevent my enemies from updating their paths every time they spawn?

Here is my Enemy code:

    CharacterController cc;
    Seeker seeker;
    Path path = null;
    Animator animator;

    OnPathDelegate onPathComplete;

    private void Start()
    {
        seeker = GetComponent<Seeker>();
        cc = GetComponent<CharacterController>();

        onPathComplete = OnPathComplete;

        StartPath();
    }

  public void StartPath()
  {
      seeker.StartPath(transform.position,
                       LevelsController.Instance.playingLevel.basement.position,
                       onPathComplete);
  }
  void OnPathComplete(Path p)
  {
      if (p.error) return;

      path = p;
      wpIndex = 0;
  }

Here is my Drag code:

public void OnDrag(Vector3 targetPos)
{
    transform.position = targetPos;
    bool invalid = InvalidPlacement();
    UpdateGraphForAllColliders();
    UpdateHighlighter(invalid);
}

void UpdateGraphForAllColliders()
{
    foreach (var c in cols)
    {
        GraphUpdateObject guo = new(c.bounds);
        AstarPath.active.UpdateGraphs(guo);
    }
}

If this is happening when your enemies spawn, I’d imagine they’re getting their path from this part of the code at the end of the Start method. If I’m misunderstanding feel free to correct me and I’ll be glad to assist more :slight_smile: