1

How to send a vector object. I am trying to send an object's location in vector format over a udp socket connection.

socket.sendto(self.cube.worldPosition,server_addr)

but i get the following error: TypeError: 'Vector' does not support the buffer interface

How can i achieve this or is there any other way to send the position of the object?

Vaibhav
  • 703
  • 1
  • 7
  • 18

1 Answers1

1

simply access the values of vector,form a list and send using pickle module

    ##player.worldPosition is the vector        
    x = player.worldPosition[0]
    y = player.worldPosition[1]
    z = player.worldPosition[2]                      
    xyz = [x,y,z] #forming the list
    ddd = pickle.dumps(xyz) #serialize the list
    self.socket.sendto(ddd,self.server_address) #off it goes 

this worked for me

Vaibhav
  • 703
  • 1
  • 7
  • 18