Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 dendens2 · Apr 14, 2013 at 08:57 PM · javascriptpathfindingpath-finding

A* nodes in the basic version of unity.

Hi, I am learning my first algorithm(A*) and I am wondering how exactly to set up the grid in unity. I know the pro version has some kind of navmesh, but I don't have that. Would I just use squares and place them all over the map? That seems really inefficient though. What do you guys do? Sorry if this is a bit broad, thanks!

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

Answer by whydoidoit · Apr 14, 2013 at 09:08 PM

The three choices are really:

  • Waypoints - connect them together by raycasting to make a mesh of nodes or manually connect them

Pros: You get a level of control over where things are, you can minimise the number of connections and deal with special areas by manual connections. Best possible solution for dynamically created areas and levels.

Cons: Coverage can be incomplete, potentially more overlapping paths, manual labour involved. Can be many connections from a node, little extra data (like costs of movement apart from distance). Dynamic obstacle avoidance is potentially more tricky.

  • Grid - identify walkable cells

Pros: You get automatic recognition of the scene geography, connections between nodes are always 4 or 8. Works extremely well if you are going to use influence maps. Good for recognising areas of potential exposure to threats etc. Good for dynamic obstacles that block paths.

Cons: Potentially wasteful, more memory usage, takes time to construct - consider baking it. Paths need smoothing or look "steppy", potentially many more nodes. Paths always have to follow blocks so there's no built in shortcutting.

  • Navmesh - create areas of negative space (places where your character can move) by creating polygons that fill it.

Pros: best possible coverage, great opportunities for best path detection and least chance of agent convergence.

Cons: hard to build, dynamic obstacles can be a challenge, less information about costs apart from distance.Not suitable for dynamically created areas due to build time.

You can potentially create a better result by combining cells from a grid to make a poor mans navmesh while retaining some of the extra data.

I wrote an article on Unity Gems on A* path finding with the grid method. I frequently also use waypoints.

Comment
Add comment · Show 12 · 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 dendens2 · Apr 14, 2013 at 09:29 PM 0
Share

I am interested in the grid method. I have a few question though. I am also not sure which article is yours. Is it this one? http://unitygems.com/astar-1-journeys-start-single-step/ After you answer I will ask the other ones, thanks!

avatar image whydoidoit · Apr 14, 2013 at 09:31 PM 0
Share

Yes that's the one.

avatar image dendens2 · Apr 14, 2013 at 10:26 PM 0
Share
 int width, height;
 //Active map of the world
 public GridCell[,] cells;

Is that in the GridCell class? I have never used classes before so I don't really know how they work.

avatar image dendens2 · Apr 14, 2013 at 10:42 PM 0
Share

Also what is the out hit in if(Physics.Raycast(currentPosition, -Vector3.up, out hit, bounds.size.y))

I am trying to convert this to JavaScript and am having a hard time because I don't know what some of the things are.

avatar image whydoidoit · Apr 14, 2013 at 10:43 PM 0
Share

Yes that's a class - which works pretty similarly in Unity Script.

Show more comments

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

12 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

Related Questions

A* optimization and path help 0 Answers

How can I convert this script to automatic fire? 2 Answers

Find a path with specific steps (moves) on a grid 0 Answers

How do i check if all tagged objects are inactive? 2 Answers

Can I convert unityscript to boo? 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