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.
When are you reading the value?  If you've assigned it to a variable, it might be reading the initial value, and ignoring any updates.  

You'll need to update the value periodically.  Possibly using an Always sensor, with a skip, if desired.  Or at certain times within the game;  collision with another object, for instance.  

You may need to access appropriate coordinate within it's location vector:  obj.pos.x