Exemplo n.º 1
0
    private void Update()
    {
        if (netId.localPlayerOwns)
        {
            Movement();
            CameraMovement();
            Shooting();
            if (NetworkClock.IsTimeToSend())
            {
                netId.SendDataOverNetwork(NetworkEventType.UpdatePosition, NetworkSubeventType.Null, transform);
            }
        }

        else
        {
            transform.position = Vector3.Lerp(lastPos, newPos, currentLerp);
            currentLerp       += lerpRatio;

            while (netId.dataQueue.Count != 0)
            {
                NetworkEvent currentData = netId.dataQueue[0];
                netId.dataQueue.RemoveAt(0);
                if (currentData.GetNetworkEventType() == NetworkEventType.UpdatePosition)
                {
                    Vector3[] newTrans = (Vector3[])currentData.GetData();
                    lastPos     = new Vector3(newPos.x, newPos.y, newPos.z);
                    newPos      = newTrans[0];
                    currentLerp = lerpRatio;

                    transform.eulerAngles = newTrans[1];
                    transform.localScale  = newTrans[2];
                }
            }
        }
    }