Example #1
0
        protected override void Update()
        {
            base.Update();

            if (IsServer)
            {
                if (!IsLocalPlayer && gameObject.CompareTag("Player"))
                {
                    if (Time.time < m_nextTime + m_extrapolationTime)
                    {
                        transform.position = Vector3.LerpUnclamped(m_lastPosition, m_nextPosition, Time.time / m_nextTime);
                        transform.rotation = Quaternion.LerpUnclamped(m_lastRotation, m_nextRotation, Time.time / m_nextTime);
                    }
                    else
                    {
                        transform.position = m_nextPosition;
                        transform.rotation = m_nextRotation;
                    }
                }

                if (Time.frameCount % m_syncInterval == 0)
                {
                    UpdatePositionMessage message = new UpdatePositionMessage(this.gameObject);
                    NetworkManager.Instance.SendMessageToClients(message);
                }

            }
            else if (IsLocalPlayer)
            {
                if (Time.frameCount % m_syncInterval == 0)
                {
                    UpdatePositionMessage message = new UpdatePositionMessage(this.gameObject);
                    NetworkManager.Instance.SendMessageToServer(message);
                }
            }
            else
            {
                if (Time.time < m_nextTime + m_extrapolationTime)
                {
                    transform.position = Vector3.LerpUnclamped(m_lastPosition, m_nextPosition, Time.time / m_nextTime);
                    transform.rotation = Quaternion.LerpUnclamped(m_lastRotation, m_nextRotation, Time.time / m_nextTime);
                }
                else
                {
                    transform.position = m_nextPosition;
                    transform.rotation = m_nextRotation;
                }
            }
        }
    public void SendMatchData(byte[] matchId, Vector3 position)
    {
//		Debug.Log ("SendMatchData");

        long opCode = 1;
        UpdatePositionMessage updatePositionMessage = new UpdatePositionMessage();

        updatePositionMessage.x = position.x;
        updatePositionMessage.y = position.y;
        updatePositionMessage.z = position.z;

        var data    = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(updatePositionMessage));
        var message = NMatchDataSendMessage.Default(matchId, opCode, data);

        Application.client.Send(message, (bool complete) => {
//			Debug.Log("Successfully sent data to match.");
        }, (INError error) => {
            Debug.LogErrorFormat("Could not send data to match: '{0}'.", error.Message);
        });
    }
Example #3
0
 private void UpdatePosition(UpdatePositionMessage msg)
 {
     _setCameraPositionMsg.Position = msg.Position;
     _controller.gameObject.SendMessage(_setCameraPositionMsg);
 }
Example #4
0
 private void UpdatePosition(UpdatePositionMessage msg)
 {
     _position = msg.Position;
 }