Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Do I have to optimize path requests myself?

Discussion in 'Navigation' started by John_Leorid, Apr 18, 2023.

  1. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    637
    I have a lot of enemies in my levels, up to 100 and they fight against the army of the player which is also up to 50 agents/units. When enemies detect the player or his troops, it takes quite some time until they start moving.

    But 90% of the enmies are just standing still (somewhere else on the map) - so why do those paths take so long to calculate? Especially as there is literally a straigt line to walk to the player?

    The NavMesh class has some functions like "NavMesh.Raycast" which is quite a fast operation. Do I have to call this myself before even calculating a path so I can just skip the calculation and assign a path with two "corners" to the NavMeshAgent or is the NavMeshSystem smart enough to do this automatically?

    Also the other Agents standing somewhere around the map - do they constantly calculate paths to their own position (because SetDestination is called once and AutoRepath is active)? Or is the system smart enough to make a simple "am I already at the destination" check to skip those path-calculations?

    It feels like I have to optimize this myself ... or could there be any other reason why agents are getting new paths with such a delay? (Delay of up to 2 Seconds)
     
  2. bonickhausen

    bonickhausen

    Joined:
    Jan 20, 2014
    Posts:
    115
    DevDunk likes this.
  3. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    637
    I see, that's what I thought. Hopefully the A* asset is on sale soon.
     
  4. GameLoomer

    GameLoomer

    Joined:
    Jan 11, 2022
    Posts:
    2