AI pathfinding, nodes , waypoints, FINISHED AND EASY TO USE IT

Ok, the title is pretty clear.

here, a video. The red cube finds the blue one.

You can adapt this script just changing the nodes and only a litte part in the script, the part in the red circle. I’ll make a tutorial soon.


IA__pathfinding.blend (215 KB)

Good job.
My only wish is the algorithm code to be written in English.

well the algorithm is something close to the A* (A star). I said “close to” because I haven’t studied the A* algorithm completely. I tried to do something simple.

You can find it in internet for sure. But in a few lines it is…

1.- You have nodes (emptys, cubes or whatever), every node can be join with a straight line with another one, I mean no obstacles between them
2.- from first node to last node, the script try diferent ways, eliminating those that step foward,
3.- The first path that reach the last node, is the right path.
4.- follow the path.

If you mean my comentaries in the code, are just a few words that you can traslate online, for example.
But it didn’t help too much, it is more for don’t get myself lost, than for a good explanation.

P.D. thank you for you comment.

Great! Very useful, at least for me!
Thank you for sharing!

you are wellcome, nice to help

This is really awesome…but how would you just make a AI track? and repeat the track? like this tutorial, you have nodes, you goto node to node but how would you just go to node to node and repeat? like a rotation.

Sorry, I don’t understand your question, can you explain it in another way?

is this code only for 2d or can it be used in 3d? like stairs and ladder?
p.s. yo tambien ablo espaniol gracias!!

kojima pro, i think i know what you are talking about, like having nodes set in a circle and have an object follow them
if that is what it is then you dont even need python you easily achieve it with logic bricks using this tutorial

hope it helps!

yes, that is the exact tutorial that i was looking at but no matter what i do i can’t achieve my goal…

Here is my topic.

kojima pro -i responded on your thread and fixed your problem!!

fisicomolon- how come the objective must remain stationary?
porque tiene que estar el objectivo sin moverse?

Well the code is used to find the path, node by node. The way the actor go from one node to another one, is not script’s bussines. I mean, if you have a game in which an actor can use ladder and stair, yes you can use the script to make him go, from one node to the next one.

I have a simple question. In your script it looks like you define the nodes and list their location. Does this have to be done? I’m thinking how this would work with 50-100 nodes, of course I guess I make a script that finds every node and puts it in the list.

Sorry, just a question,

could we find the script somewhere?:slight_smile:

Great Job!!!

Download the .blend file attached.
Open it up in Blender 2.48.1
You can view the “Pathfinding” scripts in the Text Editor.

Note that "Recast & Detour " Branch has been merged to latest Blender version, which allow path finding AI to be done easily.

I think this method is not necessary anymore since blender have a mesh navigation actuator

there is a way for locate a node in automatic for every face of a mesh? (like floor map elements, and have one node for every triangle center of its faces)

Steering in Blender is fantastic, but with more than 100 zombies my game fps drop too much, with this script i can have only 1 AI that move all zombie army, and not 100 AI (also if simple,is hard to add sensor and conditions change without have poor performance)