Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 geropellicer · Dec 25, 2018 at 07:52 PM · navmeshnavmeshagentpathfindingpathagent

Is it possible to store NavMeshAgents paths and assign them to other NavMeshAgents later?

Hi! So I'm developing a game in which in each level there are a given number of building (let's say 10, that is close to the average) that can spawn units. When a unit is born in a building, it goes to the building that has been set as target of that unit.

So far, I had the sistem set in this way: after player interaction, the unit is instantiated in the origin building, the target building is set as the destination in the NavMeshComponent of that unit and after the unit has its path calculated, it follows the path to the desired building where it is destroyed. So far so good, works.

The problem is that having 4 or 5 units going to their respective destinations at the same time causes a massive drop on the frame rate (from more than 120fps to less than 15fps).

So I figured that given that my building are static and there will not be dinamic obstacles, I could calculate all the paths between buldings at the beggining and them assign the correct path to each unit when it is instantiated. I don't know I this would help to increase the FPS.

I'm not interested in agents colliding with or avoiding each other, in fact I have the obstacle avoidance quality set to none. I'm aiming for Android and my goal is to have a maximum of about 30 units running smoothly (30 or more fps).

I can't build the paths manually using a waypont system because I plan to have many levels. So building the path from each building to the other 9 (about 90 paths per level if I have 10 buidings) would be insane.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ray2yar · Dec 28, 2018 at 03:01 PM

That's a great idea. Look into NavMeshPath and NavMesh.CalculatePath

Here's code that gets a path and assigns it to an agent.

     public Transform Target;
     NavMeshAgent Agent;
     NavMeshPath Path;
 
     void Start () {
         Agent = GetComponent<NavMeshAgent>();
         Path = new NavMeshPath();
         NavMesh.CalculatePath(transform.position, Target.position, NavMesh.AllAreas, Path);
         Agent.SetPath(Path);
     }
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.

Follow this Question

Answers Answers and Comments

104 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

Related Questions

Is it possible to assign a custom path to a NavMeshAgent? 0 Answers

Find the closest point of an Invalid or Partial path 0 Answers

Randomize NavMeshAgents path finding with same destination 1 Answer

NavMesh Update Path 0 Answers

Issue with NavMeshAgent behavior in 4.2 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