Game Development Community

aStar is going to make me cry! (SOLVED)

by Richard Petrov · in Torque Game Builder · 09/13/2011 (9:43 am) · 2 replies

I'm just kidding it's just frustrating.

I worked on this tutorial here: http://tdn.garagegames.com/wiki/TGB/Tutorials/Basic_aStar

I actually got it working fine and I was happy. I was cleaning up and changing some tiles around on the tile layer and I noticed I had two layers. One is the tile map I have with the boundaries for the AI and the other one was blank. So I figured might as well delete the blank one since I didn't need it.

That's what I did, and I made sure the layer I kept had the class "pathLayer". Now when I run from Torsion I get this error:
game/gameScripts/aStarActor.cs (126): Unable to find object: '' attempting to call function 'createPath'
Tile Layer Size is invalid

I never changed the Tile Layer Size, and it's been working fine, but now ever since I deleted a blank layer aStar isn't working!

Any ideas?

#1
09/13/2011 (10:55 am)
I solved both errors.

For this error: "Tile Layer Size is invalid"

I noticed on the Object Tree I had two t2dTileLayer's listed when I was only suppose to have one. I deleted the instance that didn't belong.

As for this error: "game/gameScripts/aStarActor.cs (126): Unable to find object: '' attempting to call function 'createPath'"

I didn't realize that objects are initialized based on their creation. Like first come first serve type of deal. So the AI was being initialized before the Tile Map was.

I just deleted the AI and the Tile Map and placed the Tile Map down first and then the AI. Everything works okay now!
#2
09/14/2011 (12:59 pm)
Hey thanks for finding that tutorial!
I've been puttering with getting a* put in to my game lately and it worked like a breeze following that tutorial.

One thing to keep in mind about the tutorial is that it's calling the startPath function onUpdate.. in practice that'd probably be massive overkill since pathfinding is such an expensive operation it'd be better to just run it on a timer.