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 AlucardJay · Dec 09, 2012 at 07:21 AM · pathfindingastar

Lost in Pathfinding

Edit :

Ok, well have been trying to understand the process, and think I'm getting closer. The only problem now is that it isn't returning the target, more accurately the way I am storing the target as a reference and how I am comparing where I am to that reference. If anything is obvious to you, please point it out. Here is my current script :

http://www.alucardj.net16.net/unityquestions/Pathfinding%20Current%20Code.js


Original Question :

Hello fellow Unites (YouNites) !

I'm attempting to build a pathfinding method for my troops in a tile-based strategy game, following the flow diagram on http://unitygems.com/astar-1-journeys-start-single-step/

alt text

While this chart looks easy, am having trouble implementing it. The first issue I had was an array out of range when added node to the closed list, I fixed that but now am having trouble working out where to calculate and assign the distance (G) value and the heuristic (F) value. At the line // open list node G score > tempCost? is as far as I got before a minor brain short circuit and subsequent meltdown !

Can anyone help out with some pointers like how to calculate G when checking a neighbour tile, or just expand on the flow diagram to include where the F and G values should be calculated.

The pathfinding needs to check the height of each neighbour tile and determine if the height difference is <= 1 then the tile is open/walkable.

This sounds like a fix my script question, but really if the flow diagram could be expanded on, that would be more than enough for me to continue. Thanks.

http://www.alucardj.net16.net/unityquestions/Pathfinding%20Original%20Question%20Code.js

Here is an example level to illustrate my project. Apparently when my colleague showed this on unity IRC there was alot of interest! : http://www.alucardj.net16.net/examples/HexGrid1.png

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 whydoidoit · Dec 09, 2012 at 08:06 AM

So I've posted a longer answer on Gems. The G score is calculated first as the temporary cost in that diagram and it becomes the G score of a node if it is the first time of reaching the node or it is lower than that node's current G score. At that point you also need to store from which mode the G score came from so that you can rebuild the path.

The F score is calculated in the last but one step of the flow chart, just before checking if there are more neighbours to consider.

Comment
Add comment · Show 25 · 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 whydoidoit · Dec 09, 2012 at 08:08 AM 0
Share

Also you should use Dictionaies - those open set/closed set adds and removes really need to be O(1) operations and they are O(n/2) as you have them.

avatar image AlucardJay · Dec 09, 2012 at 08:11 AM 0
Share

Thankyou, I was waiting to say the failing is in my comprehension, not your guide and diagrams (they are excellent). And as in the above comment, feel free to remove my posts. I just need to take a step back, and try again, possibly on a grid rather than an isometric hexagonal tile map.

avatar image whydoidoit · Dec 09, 2012 at 10:42 PM 1
Share

BTW the game concept looks v interesting!

avatar image whydoidoit · Dec 09, 2012 at 10:44 PM 3
Share

Another BTW - in a hex game (and in my cube game) you can always consider the distance between a node and it's neighbour to be 1. If you are not just plotting a navmesh with points (which knows all of its neighbours) then the only thing you need is a way to work out what the unblocked neighbours are.

avatar image Fattie · Dec 17, 2012 at 12:56 PM 1
Share

hooray! you guys rock

that was a "Heisenbug"

http://www.youtube.com/watch?v=Wod-$$anonymous$$udLNPA

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

11 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

Related Questions

A* Algorithm Node Grid Generation 2 Answers

Update Graph after GameObject destruction 1 Answer

Astar Pathfinding and Buildings 1 Answer

Astar Pathfinding not scanning graph 0 Answers

How to reach 2D Grid from script? How to reach every tilemap location and use them for pathfinding? 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