Search Unity

Why does finding a new path create a new array rather than reusing a list?

Discussion in 'Navigation' started by TheCelt, Sep 5, 2018.

  1. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    742
    This seems a bit crazy to me since it just allocates every time rather than only when the path exceeds a list capacity.

    Would it not be more performance to clear a list and reuse it rather than allocate every single time you want to find a path?

    What is up with that? And I've noticed theres no way for us to supply a list for it to return a path to either.
     
  2. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    What api call are you referring to?

    The non alloc way when finding paths manually is to use NavMesh.CalculatePath with NavmeshPath.GetCornersNonAlloc.