【发布时间】:2014-05-08 11:13:37
【问题描述】:
这是一个多层游戏,我需要发送服务器的位置和旋转值并再次从那里取回。谷歌只允许通过字节发送。这就是我正在尝试的。
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 Multiplayer 中发送位置值和旋转?你们怎么样?这种方法不会产生任何编译错误,但我有一种强烈的感觉,这不是正确的方法,还有比这更好的方法。
【问题讨论】:
-
你有解决办法吗?
标签: android unity3d google-play-services multiplayer