在blender中发送向量对象

2024-10-03 15:30:54 发布

您现在位置:Python中文网/ 问答频道 /正文

如何发送向量对象。 我试图通过udp套接字连接以矢量格式发送对象的位置。在

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

但我得到了以下错误: TypeError:“Vector”不支持缓冲区接口

我怎样才能做到这一点,或者有没有其他方法来发送对象的位置?在


Tags: 对象selfserver矢量格式错误socket向量
1条回答
网友
1楼 · 发布于 2024-10-03 15:30:54

只需访问vector的值,形成一个列表并使用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 

这对我有用

相关问题 更多 >