• 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 Zace666 · Jan 05, 2018 at 03:33 PM · navmeshpathfinding

walking through the countryside ?

I want my characters to walk from village to village, maybe seemingly at random (hopefully my AI will provide a reason for their journey), however the entity travels in straight lines to the waypoint. How can I get my characters to walk along roads or footpaths that I will create?

Comment

People who like this

0 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 Salmjak · Jan 06, 2018 at 12:26 PM 0
Share

What you need is a weighted pathfinding. Take a look at this excellent tutorial on A* if you're new to pathfinding. Otherwise, just add a weight to your nodes which is added in the heuristics calculation.

Note: A* doesn't handle "complex" shapes very well (shapes where the final path will be counter-intuitive (e.g. you have to walk further away from the goal node until you can turn and go back to the goal node), so I can recommend using a bi-directional search.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by OneCept-Games · Jan 05, 2018 at 04:23 PM

You could use Unity's build in Navigation and Pathfinding module. You could also create your own Waypoint system, which is simply just an Array of Vector2 or -3 objects, and then move your object along this route, even implement some Spline/Bezier curve math.

Comment

People who like this

0 Show 3 · 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 Zace666 · Jan 05, 2018 at 04:25 PM 0
Share

Sounds cool - I was wondering if there was a way to use the navmesh - put a weighting on the scenery. like crass and dirt, etc, then the pathway would prove to be quicker due to being a lower weight?

avatar image OneCept-Games Zace666 · Jan 06, 2018 at 10:45 AM 0
Share

Then a simple Waypoint system might be better in your case. There ar several tutorials and assets on Unity Asset Store that should solve your problem.

avatar image Zace666 OneCept-Games · Jan 06, 2018 at 02:33 PM 0
Share

but thats the point - with 100s of NPCs going about their business, the waypoint flags will be massively complex over several cities and the connecting roads and trails - im after something navmesh like that i can se a way point in a building in the next town and the entity will wander through the streets to the edge of town, take the best trail (NOT AS THE CROW FLIES) and head to the next town, down the alley ways till it gets to the allotted place.

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

77 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

Related Questions

How to edit navmesh at a runtime? 1 Answer

Trouble with Navmesh Agent and Navmesh Obstacle 0 Answers

Dealing With Multiple Navmeshes 0 Answers

Navigation Mesh + Doors 0 Answers

Navmesh on all sides of an object? 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