Unit Orders - Making Real-Time Track

Hey there, I am making a game where you are in “Bird’s Eye View” Mode and you give certain units orders. My question is how can I “select” a unit (Prop:Selected Value:1) and then use the mouse cursor to place an end point and have
1)my object track the quickest possible path?
2)make certain areas “untreadable” and have the path alter itself around such?
I am no blender newbie, so feel free to give me as much or little help as you can offer please! I certainly just can’t seem to figure this one out!
Thank you!
Jeremy B.

Well, once, you have the object selected (figuring out how to do that will not be hard, just browse around here) use this, or a mod of this script to place your objects:

import GameLogic as GL





For the pathfinding, you’ll have to use A* or BFS.
To , make stuff, ‘untreadable’, …If you get through the other three steps, this will be a cinch for you.

Good Luck!


This has really helped me, although to be honest I am less familiar with python, and have never actually dealt with A-star or Breadth-first searches before. If someone could explain how to set up a breadth-first search with this following example condition:
-The moving Object. (A cube with a marked “front-side”)
-the Object will sit upon Plane, in which no matter what the camera angle you click on the Plane and the Object will move to the clicked area and will be constrained to being “on” the Plane.
-If there is an Object in the way, the moving Object will evade it.
-The Object moving can be given a set speed, which can also be altered.
-The Object turns so it is always moving “Straight-Ahead” of where front points.

I know this is asking a lot, but I am also researching all this on my own too. Any possible help you can give me will be very much appreciated!

For pathfinding, check this thread.
For info on A*, check this.

Sorry, I don’t know much about BFS, but if I learn of a good resource, I’ll tell you.

Hope that helps!


Okay so I see how A* works, thank you so much! So… will I be able to use a single grid plane for the A* algorithm, by using the faces of the grid for each node (each face labeled)? Or should I use a field of planes side by side.

So the unofficial objective for me is:
-OBMarine *Sensor: “Prop:Selected / EQUAL / Value:1”
*Sensor: “Mouse:Scroll Over / Grid Face XX”
*Sensor: “Mouse:Left Click / Grid Face XX”
Controller: "Python script:A"

The A* script will take the face where you start,calculate the “H” heuristic with the Manhatten distance Python code(thanks again for the python link!!) add X movement cost to “G” movement property for adjacent faces, and X * (square root)2 to “G” movement property for diagonal faces. Then set calculated face in closed list. Add together “H” and “G” for face to get “F”. Repeat will all faces gradually expanding out until the target face is in closed list. Then begin at the target square and follow the trail of lowest “F” value faces back to the unit’s face. Finally, once the path is calculated, have the unit follow that exact path and once the unit reached the target face or the movement is altered/cancelled, all “G”, “H”, and “F” properties are reset to zero and all faces are once again placed in the open category. Does that sound about right? If there is anything you can add, or any way you can help me get this code started, I would once again be ever so grateful for the help! Thank you again Turin, you have been a fountain of information!

I’ll reply again as soon as I figure out the python code!
Jeremy B.

So does anyone know how to set a name for an individual face on an object?
Or to set a plane full of flat faces as Nodes for an A* algorithm?