• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by vedna400 · Aug 30, 2021 at 06:29 PM · ainavmeshagent

Navmesh Agent make big performance impact

alt text

alt text

First Image show when i enable 15 navmesh agent the fps was 80-90. Agents are simple they just go one point to another point

Second Image show when i disable 15 navmesh agent the fps was 270 to 300. Why?

Please help me out.

Navmesh agent Scrip ----------------

public class AIControl : MonoBehaviour {

 GameObject[] goalLocations;
 NavMeshAgent agent;
 private Animator anim;

 private void Awake()
 {
     anim = GetComponent<Animator>();
     goalLocations = GameObject.FindGameObjectsWithTag("goal");
     agent = this.GetComponent<NavMeshAgent>();
 }

 // Use this for initialization
 void Start () {
     agent.SetDestination(goalLocations[Random.Range(0,goalLocations.Length)].transform.position);
     anim.SetFloat("wOffset", Random.Range(0,1));
      anim.SetTrigger("isWalking");
 }

 // Update is called once per frame
 void Update () {
     if(agent.remainingDistance < 1f)
     {
         agent.SetDestination(goalLocations[Random.Range(0, goalLocations.Length)].transform.position);
     }
 }

}

screenshot-7.png (67.8 kB)
screenshot-8.png (67.8 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mateuszwallace · Aug 31, 2021 at 07:30 AM 0
Share

This impact at low fps is probably caused by numer of agents not navmesh agent component and your script itself. Try use an primitive 3d cylinder attach the same script and compare fps.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by CoughE · Sep 02, 2021 at 07:55 PM

I concur with James, there seems to be more influencing it here. I assume if you're enabling 15 different characters they all seem to be getting drawn at the same time (+ 600k tris etc). There are a few things you could do.

  1. Put characters on a different layer, and use https://docs.unity3d.com/ScriptReference/Camera-layerCullDistances.html to only draw them when in closer range (Using methods that do not draw the characters at all when not needed will give the biggest boost)

  2. Use lower poly versions of far away characters.

  3. Reduce the NavAgent.Quality of characters, especially if far away

  4. Do not update scripts or components that are not needed (hard to say without seeing your game code) when not needed.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by James-YangDan · Aug 31, 2021 at 09:02 AM

You should exclude animation and model consumption first.Avoid the influence of other factors on the results

From the picture, your rendering thread time-consuming has also doubled

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

207 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Checking if a non-walkable layer is blocking the path? (NavMeshAgent) 0 Answers

NavMeshAgent resume original position and facing direction C# 0 Answers

Nav Agent Moving Only Forwards And Backwards 0 Answers

My NavMeshAgent doesn't move at all!,Why my NavMeshAgent doesn't move at all? 0 Answers

Player's last location as a Transform 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges