public void SynchronizationData(GameObject g, Gamobjectsinfo infomation) { BaseContol operatingObj = g.GetComponent <BaseContol>(); g.transform.position = new Vector3(infomation.x, infomation.y, infomation.z); operatingObj.setDirection(infomation.angle); operatingObj.frie(infomation.state[0]); }
public override void receiveDataHandel(int outConnectionId, byte[] buffer, int receivedSize, int MT) { obj = synchronizationObj["player" + outConnectionId]; Gamobjectsinfo clientInfo = (Gamobjectsinfo)BytesToOBJ(buffer); operatingObj = obj.GetComponent <BaseContol>(); obj.transform.position = new Vector3(clientInfo.x, clientInfo.y, clientInfo.z); operatingObj.setDirection(clientInfo.angle); // operatingObj.frie(clientInfo.state[0]); }
//use UDP protocol transfer position info. //The UDPclient class initialized in the base class public override void syncData() { var BaseContol = playerObject.GetComponent <BaseContol>(); // BaseContol.NetworkId = id; print("entry synchronization function"); Gamobjectsinfo info = new Gamobjectsinfo(id, new byte[] { playerObject.GetComponent <BaseContol>().bullect }, playerObject.transform.position, playerObject.transform.rotation); adapter.UDPC.sendByte(ObjectToByteArray(info)); //adapter.sendmessage(adapter.connectionId, ObjectToByteArray(info), msgType.Data); }