Search Unity

is there a way to obtain all available NavMeshAgents in a Scene?

Discussion in 'Navigation' started by craig4android, Jun 29, 2019.

  1. craig4android

    craig4android

    Joined:
    May 8, 2019
    Posts:
    48
    is there a way to obtain all available NavMeshAgents in a Scene?
    Sure I could use getComponentInChildren for all root objects.

    But I wonder if there is a better way since the Navmesh system processes avoidance, the system should have a list anywhere. I wonder if I can read it somehow?
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,278
    Either add them to an array you can look at, or find them as you are - if you are doing this on Start and not Update there's absolutely no problem. From there you can easily keep track of new additions.

    If you use the github navmesh stuff, it may have something like that, but you'd have to look for it.