Copying localPosition with a minus still comes out as worldPosition??

When I try to position an enemy a certain distance behind the player. They both have their centers facing the same way. If I add distance +, it will show behind the player as it should, then if the player turns 180, it shows up in front.

Is it because of an added tracking actuator?

I’m not sure, but localPosition is the position of an object local to its parent (i.e. you can position a hat on a character to be +1 on the Z axis, and it’ll stay there).

If you want to place an object behind another, you should probably use the object’s worldOrientation, like:



other.worldPosition = obj.worldPosition + obj.worldOrientation.col[1] 


This isn’t the entire code, but it sets the world position of “other” to be the object’s world position plus the direction it’s heading on the Y axis. You can multiply the vector by how many Blender Units you want to place the other object away.

Thanks, what’s the .col for?

I multiply “other.worldPosition”?

The .col is to arrange the worldOrientation matrix by column so that the second row is the local Y-axis vector of the object. You can multiply that vector by the distance you want “other” to stay in front of the object (or negate the vector to have the object stay behind it).

Does this have an 2.49b equivalent in math or mathutils?

I’m not sure myself - I think matrices might have been column aligned by default back then. You might want to check the 2.49 API to see if such an attribute exists.

yes before than 2.62 the order was different .what now is :
obj.worldOrientation.col[1]
before was
obj.worldOrientation[1]

Thanks, both of you.
I was using obj.worldOrientation[1], then I tried with localOrientation[1] and both were a total mess. Kept aligning it along the world’s + or - Y axes whether I added or substracted distance. I am going to use something else.

is possible that in 2.49 obj.worldOrientation is not a instance, but just 3 tuples
if so, many operation here not doable directly.

anyway this should give the same result, if work (parent and unparent must be done “on the fly”)


other.setParent(obj)
other.localPosition = [0.0, 2.0, 0.0]
other.removeParent()