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
2
Question by LetMeOut · Jul 09, 2017 at 11:26 AM · navmeshnavmeshagentpathfindingnavigation

How to use Unity's pathfinding system without NavMeshAgent controlling my character?

I am making a zombie game and i want the zombies to use Unity's built-in pathfinding system, but i want to control the zombies myself (with a NON-kinematic rigidbody and using AddForce to move them) and have the pathfinding system just tell me where the zombie should go.

I have seen the manual, tutorials and script reference, and i was impressed to find that they all seem to take for granted that the NavMeshAgent should control the character, as i can think of various reasons why someone would not want that (such as in my case), and it seems to me that there is obviously no technical reason why this should be the case. I don't mind losing some non-core features of the system, such as off-mesh links, moving obstacle avoidance, etc.

The only thing that i could think of was to set NavMeshAgent.updatePosition to false so that it can't control the zombie's Transform, then constantly set NavMeshAgent.nextPosition to match the transform's position so that the NavMeshAgent doesn't simply continue moving in its internal simulation, then reading NavMeshAgent.path to find out the direction in which to move the zombie. But i don't know if this will work or if it will cause bugs or intense performance costs (wouldn't constantly setting NavMeshAgent.nextPosition make it have to constantly recalculate a path?).

If there is no way to achieve what i want using Unity's built-in system, then i would appreciate a recommendation on a free third-party pathfinding system that can do what i want (if there are any).

If it matters, my game is 2d top-down (not isometric, but real top-down).

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
2
Best Answer

Answer by FortisVenaliter · Jul 09, 2017 at 03:16 PM

Yes, just use the NavMesh.CalculatePath() function and nothing else. You don't even need a NavMeshAgent.

There is one big caveat to this, however. Since you're controlling movement, you have to ensure manually that the start position is properly on the NavMesh before calling CalculatePath, and you have to handle any mid-path recalculations or obstacle avoidance.

Comment
Add comment · Show 1 · 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 LetMeOut · Jul 09, 2017 at 06:53 PM 0
Share

Thanks! I will try this in 10-14 hours (i'm going to bed now because of messed up sleep). I will mark the answer as correct because if i run into any problems i can't solve it will probably be something for another question.

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

71 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

Related Questions

Put (Instantiate) Gameobject along or accross a path Unity 1 Answer

Get NavMeshAgent to look where it's going 0 Answers

How to change a NavMeshAgent angular rotation speed, 0 Answers

How do I fix two NavMeshAgents fighting for the same position? 1 Answer

Navigation Mesh + Doors 0 Answers


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