示例#1
0
    /// <summary>
    /// Updates the opponents' position, rotation, and if they have been reset
    /// </summary>
    /// <param name="_packet">Packet Received From Opponent Player</param>
    public void UpdateOpponents(RTPacket _packet)
    {
        Debug.Log(_packet.ToString());

        for (int i = 0; i < m_playerAvatarList.Length; i++)
        {
            if (m_playerAvatarList[i].name == _packet.Sender.ToString())
            { // check the name of the player matches the sender
                Debug.Log("GC| Packet sender verified: " + m_playerAvatarList[i].name);
                // we calculate the new position the player should go to be the position they are at plus the velocity. That is, their position plus the distance they traveled according to their last speed
                // 1 (Position)
                m_playerAvatarList[i].GoToPosition = (new Vector3(_packet.Data.GetVector3(1).Value.x, _packet.Data.GetVector3(1).Value.y, _packet.Data.GetVector3(1).Value.z));// + (new Vector2(_packet.Data.GetVector4(1).Value.z, _packet.Data.GetVector4(1).Value.w));
                // 2 (Rotation)
                m_playerAvatarList[i].GoToRotation = _packet.Data.GetFloat(2).Value;
                // 3 (Animator vars)
                m_playerAvatarList[i].GoToStrafeMagnitude = _packet.Data.GetVector2(3).Value.x;
                m_playerAvatarList[i].GoToDirection       = _packet.Data.GetVector2(3).Value.y;
                break; // break, because we don’t need to update any other players.
            }
        }
    }