如何发送矢量对象。 我正在尝试通过 udp 套接字连接以矢量格式发送对象的位置。
socket.sendto(self.cube.worldPosition,server_addr)
但我收到以下错误: 类型错误:“Vector”不支持缓冲区接口(interface)
我怎样才能实现这一点或者是否有其他方法来发送对象的位置?
最佳答案
简单地访问向量的值,形成一个列表并使用pickle模块发送
##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
这对我有用
关于python - 通过网络在 blender 中发送矢量对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15610574/