How to Track Object's x,y coordinates in the Game Engine?

Hello, I have a script that determines the location of my character and that of a camera.
The script, in short, makes the character move towards the camera, but it retains the coordinates from the 3D view, not from it’s ever changing coordinates in the Game Engine.

My question is how do I find out my character and camera’s x,y coordinates within the Game Engine?

Any help would be greatly appreciated.

I guess you are looking for something like this?

import GameLogic as gl
 
scene = gl.getCurrentScene()
char = scene.objects["OBchar"]
cam = scene.objects["OBcam"]
charPos = char.worldPosition
camPos = cam.worldPosition
 
factor = 0.01
vector = [(camPos[0]-charPos[0])*factor,(camPos[1]-charPos[1])*factor,(camPos[2]-charPos[2])*factor]
 
char.applyMovement(vector,0)

Yes! That is exactly what I’m looking for. Thank you very much.