private void CmdUpdatePlayer(NetworkUpdtMethod method, Vector2 value /*, int time*/) { if (isServer) { RpcUpdatePlayer(method, value /*, time*/); } }
private void UpdatePlayerNetwork(NetworkUpdtMethod method) { //int time = NetworkTransport.GetNetworkTimestamp(); if (method == NetworkUpdtMethod.SYNC_BOTH) { CmdUpdatePlayer(NetworkUpdtMethod.SYNC_VEL, rigid.velocity /*, time*/); CmdUpdatePlayer(NetworkUpdtMethod.SYNC_POS, transform.position /*, time*/); } else { if (method == NetworkUpdtMethod.SYNC_POS) { CmdUpdatePlayer(method, transform.position /*, time*/); } else { CmdUpdatePlayer(method, rigid.velocity /*, time*/); } } }
private void RpcUpdatePlayer(NetworkUpdtMethod method, Vector2 value /*, int time*/) { //Add interpolation of players and speed considering the time it took for the network to arrive here //byte e; //int delay = NetworkTransport.GetRemoteDelayTimeMS(conn.hostId, conn.connectionId, time, out e); if (!isLocalPlayer) { if (!rigid) { rigid = GetComponent <Rigidbody2D>(); } if (method == NetworkUpdtMethod.SYNC_POS) { transform.position = /*rigid.velocity * (float)delay +*/ value; } else if (method == NetworkUpdtMethod.SYNC_VEL) { rigid.velocity = /*Physics2D.gravity * (float)delay +*/ value; } } }