Global Coordinates of a Moving Mesh in GE

Hello everyone!

I was busy with a python script and it turns out it’s also a Game Engine problem rather than a Python Scripting problem alone:

My original thread if someone wants to know the whole story:
http://blenderartists.org/forum/showthread.php?t=190948

It comes down to this (My last problem from the link):

I now found out my problem is more of a GameLogic problem than a scripting-Problem…
I found a code (from 2006, http://blenderartists.org/forum/showthread.php?t=101298&highlight=getLocation ), that does follow the coordinates when the GameEngine moves an object. That is kind of what I want. It uses GameLogic variables…The problem is: Most functions are depreciated.

Code of the link:


g = GameLogic
L = g.getCurrentScene().getObjectList()
chuzzy = L["OBCube"].getPosition()
print chuzzy

I already found in the API (There is a special GameEngine API on http://www.blender.org/documentation/249PythonDoc/GE/index.html ):
Under GameTypes.KX_GameObject:
Command: worldPosition
Returns: list [x, y, z]
Info: The object’s world position.

I can’t get it to a properly working code. I hope someone can help. It would greatly help me. Very very thanks in advance!

If I get it right, you are looking for that code you posted being updated?
Try this:

import GameLogic as g
scene = g.getCurrentScene()
obj = scene.objects["OBname"] #it has to be "OB" and then the object name, like "OBCube"
pos = obj.worldPosition
print pos

Thanks!!! That’s exactly what I needed! I was thinking way to difficult because of the GameTypes.KX_GameObject thingy I guess…

It looks so easy when someone helps you =)