private void Update() { if (connector != null && connector.isConnected && connector.isInActiveRoom) { if (Time.time - lastTimeDataSent > 0.05f) { lastTimeDataSent = Time.time; Vector3 playerPos = player.localPosition; writer.Reset(); writer.Put(playerPos); connector.RaiseEventOnNearby(0, new Vector2(playerPos.x, playerPos.z), searchExtends, writer, DeliveryMethod.Sequenced); } //connector.RaiseEventOnAll(0, writer, DeliveryMethod.Sequenced); } if (Vector3.Distance(player.localPosition, playerTarget) > 0.5f) { player.localPosition = Vector3.MoveTowards(player.localPosition, playerTarget, Time.deltaTime * 15f); } foreach (var element in remoteClones) { if (Vector3.Distance(player.localPosition, element.Value.transform.localPosition) > searchExtends) { element.Value.transform.localPosition = new Vector3(0, -50, 0); } } }
public void SendTransform(Vector3 pos, Quaternion rot) { if (connector.isConnected && connector.isInActiveRoom) { if (Time.time - timeupdated > .1f) { timeupdated = Time.time; writer.Reset(); writer.Put(pos);// + new Vector3(Random.Range(-5,5),0, Random.Range(-5, 5))); writer.Put(rot); //writer.Put(System.DateTime.Now.ToFileTimeUtc()); //Debug.Log(writer.Length); connector.RaiseEventOnAll(1, writer, DeliveryMethod.Unreliable); } } }
public void SendData() { writer.Reset(); writer.Put("Message from " + id + " at " + Time.fixedTime); connector.RaiseEventOnAll(0, writer, DeliveryMethod.ReliableOrdered); }