Find shortest path

I’m really stumped on this one…

I’m attempting to make a game where you guard a castle by building towers to fend off enemies (aka a tower defense game), but I need a bit of AI so the enemies can find the shortest path to the castle, without going through the towers. It would probably be a lot like this.

I really don’t know where to start with this. The only thing I could think of would possibly be to have a sort of “matrix” of possible paths, and whenever you placed a tower down it would get rid of the paths that intersect the tower. That would be REALLY complicated, though, and I’d still need it to be able to find the shortest path. :spin:

Hi,

You could try the A* pathfinding algorithm (explanation here). I don’t use the game engine much so I can’t help with the best way to implement it though.

O_O Yeah, that’s probably what I’ll need! Shouldn’t be incredibly hard to trun into a script, either.

Thanks a lot!!

Do a search for A* here on Blender artists. People have already written the code for you :wink: