Game Development Community

Messing with A* Pathing (TGB)

by Brian Carter · 03/17/2008 (7:46 pm) · 3 comments

So I decided to take a quick break from rendering my sprites for my RPG (probably the subject of my next blog which should follow sometime next week), and turned my attention towards the problem of pathing - something that I will need in place for NPC's, monsters, and even possibly my own players movement.

Prior to Sunday I didn't even know what A* pathing was, or how extremely cool it is (when you can figure out what its doing that is). Anyhoo, after reading the beginners guide to A* Pathing a couple of times I decided to give it a shot. The page I used as a source can be found at www.gamedev.net/reference/articles/article2003.asp - a great resource I think, although the parenting could be better explained :) !! It took me all day but I finally got a basic A* pathing system written in TorqueScript to work including variable terrain costs.

A quick demo video of what I have done so far can be seen *** HERE ***

To give you an idea of the simplicity of use of the module the demo just makes 3 function calls to the A* module:

ASP::asp_Initialize( %debugLevel );

%pathlist = ASP::asp_CreatePath( %startposition, %endposition );
// Now you just iterate through the path list (a list of ordered coordinates) with
// a moveTo command on the player unit - easy and simple (and powerful)
// %pathlist is just a SimSet of Positions strings

ASP::asp_Shutdown();

Now I just need to optimize it (I used a number of SimSets which isnt the fastest solution), etc.. Also, I want to add influences, and make it work with multiple units at once. Also, I think I will try and play around with movement prediction and interception. By that I mean that if an NPC/Monster targets a player and calculates the best path to that player, but the player moves the path will recalculate and compensate for that movement.

I'm also coding this into a generic module that can be moved easily between projects, and adapted easily for different projects. I might even think about selling this as a low cost module if there is enough interest.

Watch this space .. I will post more in the coming weeks as I develop this further.

#1
03/17/2008 (8:14 pm)
If you have TGB Pro, check out this resource www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9711. It still works with the current build (TGB 1.7.2) and works well.
#2
03/17/2008 (8:33 pm)
Phillip, well dang yes I have the Pro version of TGB, and I wish I had found that yesterday; oh well, it was still a great exercise :) Although I might carry on developing this so that those that dont have access to the Pro version can still have a working A* pathing system that they can incorporate into their projects through torquescript and no engine mod. I'm also kinda waiting on Neo Binedells ISOEngine modification so I can get this working in 2.5D (2:1 iso).

I really wish they would change the search engine on this site, it really stinks.
#3
03/17/2008 (9:37 pm)
"I really wish they would change the search engine on this site, it really stinks."

The search engine is Google! :) LOL!