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 Tristsin · Feb 25, 2013 at 08:47 PM · beginnerastar

Beginner needs help with Pathfinding

Ok, what I have currently is a "Chess Board" type level, in which I can click each tile of the board to move my character. This all works fine. What I now need is some sort of path finding so that my character moves from tile to tile, rather than just making a straight line through everything to where I've asked it to move.

To better explain, imagine you've just started a game of Chess. You can't move your knight, because a pawn stands in front of it. The problem I have is that if I select my knight, and attempt to move, my knight would just pass right through my pawn to wherever I've clicked. (I'm not making Chess this is just the best example I could think of to explain my problem without taking video)

My board has other "cubes" in the middle, but instead of going around them, my character clips right through them.

 [x, x,  x,  x,  x, x, x]
 [x, x,  x,  x,  x, x, x]
 [x, o,  o, \/,  x, x, x]
 [x, o, [], [], [], x, x]
 [x, o,  o, (),  x, x, x]
 [x, x,  x,  x,  x, x, x]
 [x, x,  x,  x,  x, x, x]

Rather than the array's path below. (The o's represent the path taken, () represents my character, and the []s represent an obstacle in the way)

 [x, x,  x,  x,  x, x, x]
 [x, x,  x,  x,  x, x, x]
 [x, x,  x, \/,  x, x, x]
 [x, x, [], [o], [], x, x]
 [x, x,  x, (),  x, x, x]
 [x, x,  x,  x,  x, x, x]
 [x, x,  x,  x,  x, x, x]


I've taken a brief look at a tutorial on UnityGems I saw recommended to another user on A*, but as a beginner I found the tutorial out of my depth, or at least now explained in a way a beginner would understand. Does anyone know of a tutorial, or a something along the same lines, that could be helpful to me in my goal?

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

Answer by hoy_smallfry · Feb 25, 2013 at 09:30 PM

One of the most optimal general path finding search is A star, without a doubt. If you're just a beginner at programming, creating your own implementation of A star is going to be tricky, because it requires knowledge of graphs and graph theory, priority queues, etc.

I suggest you find a solution that's already created. Unity Pro has a pathfinding solution with NavMesh, and there are plenty of pathing plugins on the Asset Store, some are quite cheap (Simply A* - $10).

Though, if you really want to implement A* yourself (or have no choice), I suggest you read up on the following topics (roughly in this order, give or take):

  • graph data structures, what types there are(acyclic graphs, etc.), and how they can be constructed (adjacency lists, etc.)

  • graph edges and what types there are (weighted, directed, undirected, etc.).

  • common graph traversals (depth-first search, breadth-first search)

  • min heaps, and how you can make priority queues with them (C# does not come with a standard one)

  • Dijkstra's algorithm: how it works (its a modified breadth-first search!)

  • heuristics: what they are and some common ones for A* (Eudlidean, Diagonal Shortcut, Manhattan Distance, etc.)

  • A* algorithm: how it works (its a modified Dijkstra!)

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 Tristsin · Feb 25, 2013 at 09:40 PM 0
Share

So you're saying that I basically need to understand each of these topics beforehand if I wish to use/implement A* into my game?

I'll take a look at the plugins on the Asset Store, but it seems as if these things might not do exactly what I would like them to, even if they could partially simulate what I wanted, I wouldn't understand the bare basic concepts to alter it to work how I want it to leaving me back at square one. Though I guess I should research the plugin's capabilities before ruling it out. I'll take a look!

Also, sadly I do not have Unity Pro so the Nav$$anonymous$$esh usage is out of my grasp.

avatar image hoy_smallfry · Feb 26, 2013 at 12:47 AM 0
Share

you need to have some understanding of them and how they all work together to make A* possible, if you intend on implementing it.

I mean, a architect needs to know a little something about physics if he plans on building a stable bridge, right?

I edited my answer so there's less scary bullet points, btw.

avatar image Tristsin · Feb 26, 2013 at 02:58 AM 1
Share

Indeed I'd hope that architect did know a bit about physics eh?

Lol, that is much less scary. Also after brief research I've found it seems much easier to understand all these concepts than it is to understand how to implement them into script, but I guess that's what learning is for.

avatar image
2

Answer by llSalvationll · Feb 25, 2013 at 09:32 PM

I'd recommend starting here - http://www.policyalmanac.org/games/aStarTutorial.htm

A* is pretty much the gold standard in pathfinding for games today and you should really understand the idea behind it before going further. When I first tried coding pathfinding I used this tutorial and I found it explained everything far and away better than any of the other tutorials I looked at. Once you have an idea of how to implement this in a general sense, you can probably either follow the unitygems tutorial, or implement it in your own way. Apart from this, you could take a look at using navmeshes and such, which I think is a unity pro option only and may not really solve your particular issue.

Comment
Add comment · 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 Tristsin · Feb 25, 2013 at 09:36 PM 0
Share

I'll take a look man, thanks. It sounds almost exactly like what I need.

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

Multiple Cars not working 1 Answer

Where can I find tutorials for scripting in c#?? 1 Answer

Help on a basic script 2 Answers

Basic toggle timer Help! 2 Answers

help for beginner 3 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