Hi, I’m trying to show an object’s global position using In-game text. What I basically want is to have an overlay scene with text updating to show the object’s X,Y, and Z coordinates as it moves. I know that its possible to print an objects coordinates in the console, but is it possible to show them on in-game text?
import bge
cont = bge.logic.getCurrentController()
own=cont.owner
own.sendMessage('Data', str(own.worldPosition))
this will send out a message that is your position
you then need this in text object
Message(subject Data)----------python
import bge
cont=bge.logic.getCurrentController()
own = cont.owner
sensor = cont.sensors['Message']
if sensor.positive:
own['Text']=Sensor.bodies[0]
I tried that, but I’m a bit of a noob at python. I saved both scripts with the .py extension, and set up my logic, but it didn’t display the cords. I saved the first script and attached it to an “always” sensor on my object. then I attached the second scrpit with a “Message” actuator and “Data” as the subject. But all that happened was the text appeared and remained normal.
Oh, thanks very much! I’ll close the thread now, the blend showed me how.