How To Get Object Coordinates With Python?

Hi I’ve been working on my indie game for a couple days now and I found a problem that might kill the entire project.

basically I want to make a similar game to Iron Lung:

But I have not found a good way of properly displaying the players current coordinates

I found an old post from 2014 that said that it was impossible and a Spanish YouTube video that made a similar system but with logic bricks.
I was going to follow the Spanish YouTube Tutorial but I quickly realized that I would have to make and edit over 1048576 individual cubes to get it to work.
this would obviously be incredibly laggy and humanly impossible…

so I wanted to ask if there was a way to get it to work with empties and python instead.
the only problem is I’m a horrible programmer lol but any work around or suggestion would be incredibly helpful :grin:

import bge
own = bge.logic.getCurrentController().owner
own['X'] = own.worldPosition[0]
own['Y'] = own.worldPosition[1]

add the property X and Y to the empty and use copy property vs it in the text

this will pass properties into the object you can use*


edited** I forgot


thank you!!! it works!!! :grin:

1 Like