# How to get current position of an object using Blender's Python API in BGE?

I'm updating an objects location using a Simple Motion Actuator. I see it move on the screen.

In Python I want to get the objects' current position.

scene = bge.logic.getCurrentScene()
obj = scene.objects['Sphere.002']     # The object the actuators are defined on

obj.position
obj.worldPosition
obj.localPosition


I've tried these three methods of the object, but all of them only show the original position of the object, not the current position based on the changes made by the logic bricks.

Here's another example of what I'm doing wrong, it seems to be the same problem.

I have a text object, I've defined a text game property that I increase or decrease with a keyboard sensor. When I print the value of the text it only prints the original value of 0.5 not the value I see on the screen.

print(bge.logic.getCurrentScene().objects['mytextobject'].text)


This always prints the original value, not the value that is updated from the logic bricks. This must be a trivial error, but I can't figure out what to do. I've looked at all the properties of the scene.object and I don't see anything that looks like it might give me the expected result.

• What changes have you made?. obj.worldPosition = current world position. Maybe 'Sphere.002' never move. Please add some images. Nov 28 '17 at 1:13
• Be aware controllers get executed BEFORE the active actuators run. Nov 28 '17 at 6:06

• It's during the execution of the game that I don't see the changes. I print this value out constantly: bge.logic.getCurrentScene().objects['Sphere.002'].position.z and the object Sphere.002 moves on the screen in response to my keyboard (using logic bricks). But it always prints the same original value of 3.25, where it starts on the screen. Nov 28 '17 at 17:35