• 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
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 t$$anonymous$$nk 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 t$$anonymous$$s 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 t$$anonymous$$ng that i could t$$anonymous$$nk 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 w$$anonymous$$ch to move the zombie. But i don't know if t$$anonymous$$s 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 ac$$anonymous$$eve what i want using Unity's built-in system, then i would appreciate a recommendation on a free t$$anonymous$$rd-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
Nordwolf
LukeNukem44

People who like this

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

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

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

There is one big caveat to t$$anonymous$$s, 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
LetMeOut
LukeNukem44

People who like this

2 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.

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

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

How to build a custom shape NavMesh Area 1 Answer

Increase size of obstacle - navmesh 1 Answer

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


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