A* Pathfinding module with physics collision?

Hello :smiley:
I have been trying to work with the A* pathfinding module
( Which can be found here: http://www.coronalabs.com/blog/2011/11/02/guest-post-the-a-algorithm/ )
recently.

I tried to apply the pathfinding algorithm to some physics bodies. However, I noticed that A* completely ignores the collisions with physics.

Is there any way to make both work together? o.o [import]uid: 191248 topic_id: 34839 reply_id: 334839[/import]

The A* algorithm won’t figure out where you placed physics objects, it will only work its way around objects that your explicitly stated it can’t go through. For example 1’s in your array will represent areas it can’t use and 0 would be areas where it can find a path. Have you set up your array correctly to show the algorithm where the obstacles are?

Attaching physics bodies your moving with A* works fine and i’ve got a fully working tower defense game using it, if thats what you meant.

Also, before you go much further with A* you need to know that it can lag horribly with lots of enemies on the screen if you have to keep on recalculating there paths. I was going to release my A* tower defense game as a template, but when i tested it on device with lots of enemies on the screen the performance was pretty bad. That doesn’t mean it can’t be done efficiently, it just means that i obviously didn’t lol. [import]uid: 69826 topic_id: 34839 reply_id: 138458[/import]

Well, then I will have to redraw the grid everytime my map changes, right? ( For example after you build a tower) Is there any more efficient way to do that?

And about physics, my question was rather: If you spawn a few enemies in a tower defense, and apply A* to all of them. The enemies won’t collide with eachother and just follow the path A* gave them XD Is there any way I can change that? [import]uid: 191248 topic_id: 34839 reply_id: 138460[/import]

TandG - you were going to release it as a template? I’d buy that right now even with the A* not working 100%. If you want to talk outside of the forum, I’m at thatssopanda (a) gmail.com [import]uid: 14218 topic_id: 34839 reply_id: 138463[/import]

The A* algorithm won’t figure out where you placed physics objects, it will only work its way around objects that your explicitly stated it can’t go through. For example 1’s in your array will represent areas it can’t use and 0 would be areas where it can find a path. Have you set up your array correctly to show the algorithm where the obstacles are?

Attaching physics bodies your moving with A* works fine and i’ve got a fully working tower defense game using it, if thats what you meant.

Also, before you go much further with A* you need to know that it can lag horribly with lots of enemies on the screen if you have to keep on recalculating there paths. I was going to release my A* tower defense game as a template, but when i tested it on device with lots of enemies on the screen the performance was pretty bad. That doesn’t mean it can’t be done efficiently, it just means that i obviously didn’t lol. [import]uid: 69826 topic_id: 34839 reply_id: 138458[/import]

Well, then I will have to redraw the grid everytime my map changes, right? ( For example after you build a tower) Is there any more efficient way to do that?

And about physics, my question was rather: If you spawn a few enemies in a tower defense, and apply A* to all of them. The enemies won’t collide with eachother and just follow the path A* gave them XD Is there any way I can change that? [import]uid: 191248 topic_id: 34839 reply_id: 138460[/import]

TandG - you were going to release it as a template? I’d buy that right now even with the A* not working 100%. If you want to talk outside of the forum, I’m at thatssopanda (a) gmail.com [import]uid: 14218 topic_id: 34839 reply_id: 138463[/import]