Sending with Buffer ads a tiny extra on height

Hi there currently I have a small problem with sending the players position. He is always making a little wobbling up and down thingy. I am sending the transform.rotation via a Buffer within a BitConverter. (I was thinking about some performance improvements) but when I send the y position of 1.0 I get in return the y position of 1.1.

Code:
private void Update()
    {
        if (!m_PhotonView.IsMine)
        {
            if (transform != null)
            {
                m_NewRotation = transform.rotation;
                m_NewRotation.y = Mathf.Lerp(m_NewRotation.y, m_NewRotY, Time.deltaTime * 20);
                m_NewRotation.w = m_NewRotW;
                m_NewPos += (transform.position - m_NewPos) * m_Lag;
                transform.position = Vector3.Lerp(transform.position, m_NewPos, Time.deltaTime * 20);
                transform.rotation = m_NewRotation;
            }
        }
    }

    void IPunObservable.OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            stream.SendNext(CreateSendPackage());
        }
        else
        {
            OpenReceivePackage((byte[])stream.ReceiveNext());
            m_Lag = Mathf.Abs((float)(PhotonNetwork.Time - info.SentServerTime));
        }
    }

    private byte[] CreateSendPackage()
    {
        byte[] sendPackage = new byte[sizeof(float) * 5];
        Buffer.BlockCopy(BitConverter.GetBytes(transform.position.x), 0, sendPackage, 0 * sizeof(float), sizeof(float));
        Buffer.BlockCopy(BitConverter.GetBytes(transform.position.y), 0, sendPackage, 1 * sizeof(float), sizeof(float));
        Buffer.BlockCopy(BitConverter.GetBytes(transform.position.z), 0, sendPackage, 2 * sizeof(float), sizeof(float));
        Buffer.BlockCopy(BitConverter.GetBytes(transform.rotation.y), 0, sendPackage, 3 * sizeof(float), sizeof(float));
        Buffer.BlockCopy(BitConverter.GetBytes(transform.rotation.w), 0, sendPackage, 4 * sizeof(float), sizeof(float));
        return sendPackage;
    }

    private void OpenReceivePackage(byte[] _receivePackage)
    {
        m_NewPos.x = BitConverter.ToSingle(_receivePackage, 0 * sizeof(float));
        m_NewPos.y = BitConverter.ToSingle(_receivePackage, 1 * sizeof(float));
        m_NewPos.z = BitConverter.ToSingle(_receivePackage, 2 * sizeof(float));
        m_NewRotY = BitConverter.ToSingle(_receivePackage, 3 * sizeof(float));
        m_NewRotW = BitConverter.ToSingle(_receivePackage, 4 * sizeof(float));
    }

Important Parts of Movement:
private void Update()
    {
        m_MoveHorizontal = Input.GetAxisRaw("Horizontal");
        m_MoveVertical = Input.GetAxisRaw("Vertical");
    }

private void FixedUpdate()
    {
        m_NavMeshAgent.SetDestination(new Vector3(m_MoveHorizontal, 0, m_MoveVertical) + transform.position);
    }
Sign In or Register to comment.