コード例 #1
0
    public void FixedUpdate()
    {
        if (localPlayer && localPlayer.IsAlive)
        {
            Transform curTransform = localPlayer.transform;
            Vector3   moveVector   = Vector3.zero;
            if (Input.GetKey(KeyCode.W))
            {
                moveVector += curTransform.forward;
            }
            if (Input.GetKey(KeyCode.S))
            {
                moveVector -= curTransform.forward;
            }
            if (Input.GetKey(KeyCode.A))
            {
                moveVector -= curTransform.right;
            }
            if (Input.GetKey(KeyCode.D))
            {
                moveVector += curTransform.right;
            }

            // mouse right drag
            float rotationValue = Input.GetAxis("Mouse X");
            float verticalValue = Input.GetAxis("Mouse Y");
            StartCoroutine(ASyncUpdateTransform(localPlayer, moveVector, rotationValue, verticalValue, GameplayManager.estimatedLag));

            if (Input.GetMouseButton(0) || Input.GetKeyDown(KeyCode.Space))
            {
                if (localPlayer.CanAttack())
                {
                    AddCommand(PlayerCommand.FireBullet);
                    StartCoroutine(AsyncFireBullet(localPlayer, GameplayManager.estimatedLag));
                }
            }
        }
    }