[SOLVED] alignAxisToVector and linked libraries

Hi, just me making a noob question again.

I need to use alignAxisToVector to a object that is in added from a linked library (a group), the problem is that the object always return the same worldPosition and localPosition, even if it has moved (the movement is done by a script in the library, not the main file), so the rotation will always point to the same place.

Any ideas what I’m doing wrong?

worldPosition delivers a reference to the position (the real position) which changes when you perform a change (motion, set position etc.).

If you want to store the current value you need to make a copy with worldPosition.copy().

The same belongs to worldOrientation and the local* attributes.

The problem seems to be that worldPosition actually doesn’t change with motion, set position, etc…
If I have a file with a simple


def main(cont):
     cont.owner.localPosition.x +=1
     print(cont.owner.worldPosition)

linked to a always sensor.

and in a separate file:


scene = bge.logic.getCurrentScene()
obj = scene.addObject('object', 'Empty')
def main(cont):
    print(obj.worldPosition)

linked to always sensor. object is linked object from above

one will always print the correct position, the other will always print <Vector (0, 0, 0)>.
The transformation seems to be applied in the ‘space’ of the original file, which is useless to me, I need the position of the stuff in the scene I’m looking at.

Are you sure that “obj” is the object you want to deal with? It is outside the local scope (of the function).

Well, seem likes it was just me being stupid, sorry folks. I just have to reference the objects in the groups, the groups themselves are static.
so for exemple:


someobj.alignAxisToVector(obj.groupMembers[0].localPosition, 1)

works just fine.