# Find relative direction

Track your character to an object is easy with Edit Object auctuator, but when I need the angle of the relative direction this seems little comlex. If there a method to get relative direction and relative position? If there are not, how could I calc them from other functions? (I can’t understand what orientation means)

Relative position: getPosition() gives you a vector [x,y,z] coordinates

Relative direction: getOrientation() gives you the 3x3 orientation matrix

To calculate the rotation angles is extremly difficult especially within 3D space.

It might be easier if you say what you want to achive. There might be some easier ways to deal with that. e.g. orientation matrix = [[1,0,0],[0,1,0],[0,0,1]] means no rotation within the worlds coordinates.

i can think of two ways to get the angle of direction.

1. only change your angle with setOrientation that way you can keep track of where the angle is.

2. Parent a empty infront of your character and then vertex parent a empty to the right of your character then using the position co-ordinates of the two emptys and your character to calculate the angle.

hope that helps

The reasom I want the angle in python is I would like control player and NPC with the same behavior file, and NPCs will need this to make decision. This game will use Genetic Algorithm to makes NPCs self-learning so they may need more information to figure out themselvs situation too.

Only change angle with setOrientation only works good when objects all move on the same line or this will not easier than calc from getOrientation and getPosition. Multi sensor(this makes me remembering the AI game I have played named Mindrover) is a fast way for now, I’ll take this if there are not a good(fast for computer) enough function.