Android 如何发送transform.position和transform.rotation值?

Android 如何发送transform.position和transform.rotation值?,android,unity3d,google-play-services,multiplayer,Android,Unity3d,Google Play Services,Multiplayer,这是一个多层游戏,我需要发送服务器的位置和旋转值,然后从那里再次获取。谷歌只允许通过字节发送。这就是我正在尝试的 float aa; float bb; float cc; byte[] xx =new byte[5]; byte[] yy =new byte[5]; byte[] zz =new byte[5]; Update() { aa=transform.postion.x; bb=transform.postion.y; cc = transform.postion.z; xx

这是一个多层游戏,我需要发送服务器的位置和旋转值,然后从那里再次获取。谷歌只允许通过字节发送。这就是我正在尝试的

float aa;
float bb;
float cc;


byte[] xx =new byte[5];
byte[] yy =new byte[5];
byte[] zz =new byte[5];

Update()
{
aa=transform.postion.x;
bb=transform.postion.y;
cc = transform.postion.z;

xx = System.BitConverter.GetBytes (aa);
yy = System.BitConverter.GetBytes(bb);
zz = System.BitConverter.GetBytes(cc);

PlayGamesPlatform.Instance.RealTime..SendMessageToAll(false,xx);
PlayGamesPlatform.Instance.RealTime.SendMessageToAll(false,yy);
PlayGamesPlatform.Instance.RealTime.SendMessageToAll(false,zz);

}
如果我以这种方式发送,我如何知道发送的是什么数据

public void OnRealTimeMessageReceived(bool isReliable, string senderId, byte[] data) {
 if(data[0]==(byte)'R' )
 {
  //Convert back the data
  float xyz = System.BitConverter.ToSingle(data,0);
 }
 }

所以我的问题是如何通过Unity3D在Google Play多人游戏中发送位置值和旋转?你们是怎么做到的?此方法不会产生任何编译错误,但我强烈感觉这不是正确的方法,还有比此更好的方法。

在您的示例中使用它会更容易。然而,请注意,在多人游戏中工作总是一个权衡的游戏,你必须非常确定你想要实现什么。大型RTS的网络代码与快节奏的FPS完全不同。

我正在使用Google Play多人游戏服务。你有什么解决方案吗?