A* Pathfinding 2.2 released! With loads of new features!

Hi

NOTE: A newer version has been released (version 2.5), check it out here

Now version 2.2 of my out-of-the-box pathfinding system is released!!
The project provides easy to set up and fast pathfinding in Unity.
It’s free and it works on indie (now called only “Unity”) as well as Pro, it does also work on the iPhone.

This new version features:

Cached paths
Now you can cache paths so you don’t have to calculate the same path multiple times, great for RTS games.

Simple is better
Now the script can simplify any path so it takes the most direct route, no more weird corners!!

Straight line testing
The script can test if a straight path is available to the target before it wastes time calculating it.

Easier and better editor
The editor now contains tooltips to make it easier for you to understand what the controls are for.

Better debugging
You can now see how big the angles are in the scene and you can see runtime information such as the H G variables.

Also there are some bug fixes:

2 Critical bugs fixed
If you haven’t experienced crashes sometimes you are lucky!
Here’s the fix anyway!

It’s working in 2.6 again
The script hasn’t worked in Unity 2.6, until now!

The project is free as before and you can download it here:
http://www.arongranberg.com/unity/a-pathfinding/

You can also test a demo here:
http://www.arongranberg.com/unity/a-pathfinding/terrain/
and here:
http://www.arongranberg.com/unity/a-pathfinding/building/

221992--8047--$bild_6_copy_102.png
221992--8048--$bild_5_copy_172.png
221992--8049--$terraingrid2_298.png

Well done, you cant possibly imagine in how impressed I am. : )

though if you click on the boxes in the building level the robot gets stuck in them

This is FANTASTIC! Thank you for sharing this with everyone (especially me!) :slight_smile:

Really great work, man.

Neat, that is awesome. I may very well use this someday and give full credit to your brilliance. :smile:

another amazing work!! much appreciate!!

This looks really cool.
One question, could this be used in a dynamic environment ?
To be more specific, imagine a RTS game in space, there’s no obstacles, the grid would be just a plane, and the obstacles would be other ships moving around, so it would need to be dynamic.
Would this work ?

thanks,
Bruno

I would like to know that too.

that’s good! :slight_smile: ]

but i cann’t open it in unity2.5 :frowning:

didnt notice its unity 2.6 now?

Btw, Epic nice x) might be using this!

Is there any special consideration that needs to be taken when using this for indoor scenes? Whenever I try to create a grid inside(a hallway, for example), it ends up filled with invalid nodes. If I expand the grid to encapsulate the room and some of the area outside, the outside grid area is constructed correctly.

Anyone have any performance numbers of this running on a regular iPhone 3G? What’s the frametime impact of 5-20 different objects performing pathing on a realistic iphone sized map?

Thanks for all the positive response! :smile:

@ bpatters
No, sorry, I don’t have an Unity iPhone license so I can’t test it.

@defmech
I think the script is thinking of the floor as an obstacle.
Try changing the layermask in the walkable test settings (use the capsule mode).

@killer1390 BigB
This can work, although it depends on if all ships are going to move at once, and if so, how fast.
If you calculate a path around a ship that is moving, when you get to the point where the ship was, it isn’t there anymore and thus the ship is going to follow a path around an obstacle which isn’t there.
If you can give me some more info about the scenario you are thinking of I might be able to tell you more.

Brilliant, absolutely brilliant. I expected this to be commercial, yet it still free. Thank you for doing this.

Has UT tried to hire you yet? They certainly should :slight_smile:

Are there any instructions on how a noob to unity can use this? What do you do with the files - what’s relevant in the package that you download?

I have an existing project I’d like to try this out in - but not sure what I need to grab to make this work?

Well, it’s pretty much what you just said. If i choose a group of ships, and send them somewhere, they will all start moving at the same time, to the same destiny, but with diferent points of origin.
I assume then, that the system calculates the path before the movement actually starts, and won’t be re-checking as the object moves torwards the destiny ?
thanks :slight_smile:
Bruno

Hmm, you could script it into the AI to scan for close friendly units and enemies and make det code avoid them, that would work real time, but not via det Path nodes? = )
like
scan → if closer than → move x-z line or move to another node?

Hey Aron, I noticed an issue when I move obstacles arround and then rescan the map, it will not update the grid properly in some cases.

Say I add an obstacle and then scan the map, it will correctly flag the nodes bellow the obstacle as unwalkable, but if I reposition that obstacle and rescan the map it won’t flag the new nodes bellow this new position as unwalkable but the nodes where the obstacle was previously will be flagged as walkable, but If I move the obscale back to its original place and then scan it will flag those nodes as unwalkable again.

What’s more strange is that if I save the scene, reopen it and then scan the map it will work properly.

This tells me that it’s a refresh issue of some kind, but I’m not 100% sure.

I’m trying to figure out a way to fix it, any ideas?

EDIT: I press play and it fixes itself aswell

Hi

Of some reason I haven’t got any updates of this thread, so I haven’t seen the new replies until now.

@ratamorph
Actually I have no idea, the script doesn’t use any cached data when calculating a new grid, if it does work when you start the game then it could be one thing though, the grid is calculated a bit differently when in the editor, so you can try to change the script to calculate the grid in the editor in the same way as on startup.

To do that you should replace the code in the Scan function in the editor script to this:

((AstarPath)target).Scan (true,0);

Hope it works! :smile:

@Bruno
Yes that’s correct, the path will be calculated once.

I don’t have a clear solution for that one either, I have the same problem in my RTS game I’m making, but I haven’t found a good solution yet.
I tried to change the grid every time a unit stops and make that node unwalkable, it worked quite good, but it wont work for constantly moving units.

Hey Aron I tried your suggestion and still have the issue, I was wondering if you are experiencing the same issue.

I managed to single it out to the capsule test, even made a very simple scene to make sure it wasn’t your code at which point figured it was a bug and made the report.

I’d like to hear who also has this issue, maybe it’s a Mac OS bug?

Yep, I have the bug too (got it yesterday), I still have no idea, it seams like the editor isn’t refreashing the scene when not in play mode.