Anyone familiar with A* pathfinding / have a working example project that I can pull

Hello,

I recently tried implementing the A*pathfinding system, but found that even after following the (albeit brief integration tutorial) it would always flag the (-1, -1, -1) error. I have a feeling that the int3 struct doesn’t like the vector3? So that the constructure is faulty, making it ALWAYS default to the negative values, even when passed them.

That or I’m very much so ‘doinitwrong’. :frowning:

It sounds like your trying to implement an already existing A* project, but you don’t give any specifics (a link or name), so I don’t know for sure.

If you are trying to roll your own solution, I have attached an A* project I have recently created.

To use it, you place GameObjects (must be tagged “Node”) around your map and open the Custom Editor (Pathfinding->Create) and press “Create Node Connections”.

Its not the easiest to follow ( no comments :frowning: ) but you should be able to learn something from it.

Then again, you’re probably asking about a specific project that you neglected to link!! =P

EDIT: Updated package with sample Scene. Read how to use it a few posts down.

611863–21771–$AStarUpdated.unitypackage (18.3 KB)

Oh, lol. I thought A* was the name of the ONLY pathfinding system in Unity, turns out its a method.

here it is http://www.arongranberg.com/unity/a-pathfinding/

No worries, from the number of downloads my package got, it looks like I helped out at least 6 people regardless :slight_smile:

Unfortunately I cannot help you with your problem having never used that package myself.

I’d like to learn how to implement A*, but can’t figure out how to use the package. Could you add a simple scene in the package?

Sure, I attached the updated version. I added a scene, and a layer to ignore raycasts during Node linking.

Instructions for setting up your own nodes (with my project):

  1. Create a Node prefab (empty GameObject tagged ‘Node’)
  2. Place them around your level.
  3. If there are objects that shouldn’t affect Node connections, make a custom layer for them, and add them to it.
  4. Open the Editor (Pathfinding->Create), input the number of your custom layer to ignore (-1 if no layer), and select “Create Node Connections”.
  5. The actual Pathfinding is done in Pathfinder.cs

NOTE: It uses a Level GameObject to hold all the lists.

To use the sample scene, click inside the maze, and the cube will move to the nearest node to the point you selected.

I will edit my first post with the updated package as well.

Sorry for the thread hijack :slight_smile:

611863–21771–$AStarUpdated.unitypackage (18.3 KB)

Thanks so much Dman

That is a nice sample

Thanks so much!

If you are interested, SimplePath is available on the asset store for $60. SimplePath is a pathfinding solution, and uses A* search.

Is the pathfinding technique similar to the one found on this page?

http://www.policyalmanac.org/games/aStarTutorial.htm

Yes it is.