这是一个多层游戏,我需要发送服务器的位置和旋转值,并从那里取回它,again.Google只允许通过字节发送。这就是我正在尝试的。
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多人游戏中发送位置值和旋转?你们是怎么做到的?这种方法不会给出任何编译错误,但我强烈地感觉到这不是正确的方法,还有比这更好的方法。
发布于 2014-05-08 20:38:47
在您的示例中使用State Synchronization会容易得多。然而,请注意,在多人游戏中工作始终是一个权衡的游戏,您必须非常确定您想要实现的目标。大规模RTS的组网代码与快节奏的FPS完全不同。
https://stackoverflow.com/questions/23540156
复制相似问题