I'm using this code to send information to Pure Data, in the Python console I see the two different variables, however Pure Data keeps receiving them added together not as two separate numbers.
import bge
# run main program
main()
import socket
# get controller
cont2 = bge.logic.getCurrentController()
# get object that controller is attached to
owner2 = cont2.owner
# get the current scene
scene = bge.logic.getCurrentScene()
# get a list of the objects in the scene
objList = scene.objects
# get object named Box
enemy = objList["enemy"]
enemy2 = objList["enemy2"]
# get the distance between them
distance = owner2.getDistanceTo(enemy)
XValue = distance
print (distance)
# get the distance between them
distance2 = owner2.getDistanceTo(enemy2)
XValue = distance2
print (distance2)
tsr = str(distance + distance2)
tsr += ';'
host = '127.0.0.1'
port = 50007
msg = '123456;'
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.send(tsr.encode())
s.shutdown(0)
s.close()
I need to send up to 10 different distances from objects, this is to do with finding distances from enemies
See Question&Answers more detail:os