# Decide which direction is faster to spin to reach target?

How do I use vectors (the angle I face) , and (the angle to the next point on a navmesh)

``````
S=cont.actuators['Steering']
mesh=S.navmesh
path =mesh.findPath(own.worldPosition,own['NavTarget'].worldPosition)
print(path[1])
angle = Vector(path[1]-own.worldPosition)
angle = angle.angle(own.worldOrientation.col[0])
print(angle)
if angle&lt;.25:
cont.activate(S)
else:
own.localLinearVelocity.x*=.5
own.localLinearVelocity.y*=.5
cont.deactivate(S)
##Need help here

``````

is what I have so far, but I want it to spin to face the next point, if the angle distance is over .25,

this is so a actor will not start walking forward if the angle distance is over .25, and spin in place instead

it looks odd when actors back up and spin around at the same time to come face you.

ok, it turns out alignAxisTo Vect is great for deciding on it’s own,

now how do I decide how to play the spin animation? (as I don’t know which way it will choose?)

also

PathTo = navmesh.findPath(start,Finish)

is the end of the path PathTo[-1] or is the end PathTo[0] ?

Use the angle_signed method. With the way you currently have your code, a positive return value means you should rotate your character counterclockwise and a negative return value means you should rotate your character clockwise. Note that you need to make both vectors 2D in order to use them with the angle_signed method.

Untested but try

``````
vecto = own.getVectTo(own['NavTarget'])
sides = own.getAxisVect([1,0,0]).dot(vecto[1])
if sides &gt; 0.1: # right
turn right
if sides &lt; -0.1: # left
turn left
``````

so this list of points that the function FindPath returns,

what is it exactly?

I am having trouble using

AlignAxisToVect(own.getVectTo(path[0])[1],0,.125)

To answer your previous question. To reach the last point in the path you would use path[-1], path[0] is the point were the object if following. For your next problem… Your trying to call the position of your robot and then finding the value of some list… So what you need to do is do
AlignAxisToVect(own.getVectTo(path[1],0,.125). What is nice is that as soon as your object hit the first point in the list that point is removed.

Got all the pathfinding working, next I am on to the turn animations!

Hello! I don’t know if you solved the problem but I tested Mobious method and it works fine:

http://www.pasteall.org/blend/37582

Sorry if I misanderstood the question.