コード例 #1
0
        private void Update()
        {
            GroundSanityCheck();

            if (_dashing)
            {
                _dashTimer += Time.deltaTime;
                return;
            }

            dashCountdown -= Time.deltaTime;


            if (Input.GetKeyDown(KeyCode.LeftShift) && dashCountdown <= 0 && Input.GetKey(KeyCode.A))
            {
                StartCoroutine(Dash(DashDirection.Left));
            }
            else if (Input.GetKeyDown(KeyCode.LeftShift) && dashCountdown <= 0 && Input.GetKey(KeyCode.D))
            {
                StartCoroutine(Dash(DashDirection.Right));
            }
            else if (Input.GetKeyDown(KeyCode.LeftShift) && dashCountdown <= 0 && Input.GetKey(KeyCode.S))
            {
                StartCoroutine(Dash(DashDirection.Backwards));
            }
            else if (Input.GetKeyDown(KeyCode.LeftShift) && dashCountdown <= 0)
            {
                StartCoroutine(Dash(DashDirection.Forward));
            }

            var x = Input.GetAxis("Horizontal");
            var z = Input.GetAxis("Vertical");

            if (Input.GetKeyDown(KeyCode.Space) && _jumpCount < _maxJumpCount)
            {
                _velocity.y = Mathf.Sqrt(jumpHeight * -2f * Gravity);
                _jumpCount++;
            }

            _velocity.y += Gravity * Time.deltaTime;

            var playerTransform = transform;
            var moveVector      = playerTransform.right * x + playerTransform.forward * z;

            Dashcooldown.CooldownCountdown(dashCountdown, dashCooldown);
            MoveController(moveVector);
        }