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 coolbird22 · May 24, 2015 at 03:02 PM · pathfindingtile

(Pathfinding) How to take a particular path, while avoiding others on a flat terrain ?

Kindly check the attached image. How do I go about making an object take a particular path from point A to point B. The path is shown in grey in the picture attached. Further questions are as follows: How do I make sure that the object doesn't fall down a pit or a cliff ? How do I make the object avoid the water ? If the object landed up on the green area, how can I make it move to the nearest grey path area and continue towards its' destination, instead of making it continue to move to the destination on the green area itself ?

Every box is a single tile with each type as a prefab. So, every green tile is 1 prefab, every path tile is 1 prefab, every tree is 1 prefab.

Kindly point me to the best resources that will aid me in achieving this behavior. In the future, I also intend to include sloped paths, but that will still be tile based. So basically, each tile will probable hold a priority that the object will check before moving over it (or not).

Thanks for taking the time to read this. alt text

pathfindingquestion.png (126.8 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by coolbird22 · May 25, 2015 at 07:20 PM

I didn't realize NavMesh Layers was now free in Unity. I used it and found it to be exactly what I required. Check it out here. Kindly note that the docs dont seem to have been updated, and still show that it is only available in the Pro version of Unity.

Comment
Add comment · 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
1

Answer by Megolas · May 24, 2015 at 07:49 PM

You can add a node (Just an empty transform) to each turn, then connect them (Each one holds an array of all the nodes it connects to). From here, you can use an djikstra or A* algorithm so the unit will follow the path.

It won't fall in a cliff or enter the water if not node connection passes there - just make its position lerp from one nodes position to another.

Sorry for the rushed answer, don't have much time - if you need help feel free to ask.

Comment
Add comment · 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 coolbird22 · May 24, 2015 at 08:00 PM 0
Share

$$anonymous$$y coding knowledge is beginner at best, though from what I could understand from your answer, that would mean that each node would contain a fixed value of that tiles' transform, which would most probably be the center that tile. This isn't what I was hoping to make. The game object should be able to travel anywhere on the tile and find a way ahead. Also, there are scenarios when the game object is picked up and dropped on the grass tiles (green), so going by your answer, the game object will not be able to continue to move anymore, since the grass tile wont have a transform node that is inside the array. At that point, the game object should be able to locate the nearest Path tile, and continue towards its' destination while staying on the path.

Thanks for replying and I appreciate the reply.

avatar image Megolas · May 24, 2015 at 08:10 PM 0
Share

Actually, since you usually don't travel to nodes, you just find a node that manages to raycast to the point you want. Add it to the calculation as part of the distance, and you've got yourself exactly what you wanted.

If you do end up using this method, though, add checks that you aren't going past a cliff on the way from the last node to your point. You can do that by having cliff nodes and finding line intersections between two cliff nodes and the last walking node and the target.

Again - sorry for the rushed comment.

avatar image coolbird22 · May 24, 2015 at 08:57 PM 0
Share

Ok, that makes more sense. So does this method qualify to be called as a Waypoint method ? Could you kindly point to resources/tutorials that could help me achieve something like this ? Also, kindly reply at your own pace. I'm not in a hurry.

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

20 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

Related Questions

2D Tile Road Pathfinding 2 Answers

[C#] Find shortest path from point A to B? 2 Answers

2D Tile Based Game problem with A * Pathfinding Project 0 Answers

Pathfinding. Does not "walk" on every tile. 1 Answer

TILE MOVEMENT 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