// Update is called once per frame
    void Update()
    {
        PlayAnimations();
        CheckIfGrounded();
        checkIfWallSliding();
        dashing = dashController.IsDashing();

        if (Input.GetButtonDown("Jump") && (onGround || isWallSliding) && !isGunLoading && !jumping && !takingDamage)
        {
            jumping = true;
            wallJumpControlPoint    = new Vector3[3];
            wallJumpControlPoint[0] = body.position;
            wallJumpControlPoint[1] = new Vector3(body.position.x + 4, body.position.y + 2);
            wallJumpControlPoint[2] = new Vector3(body.position.x, body.position.y + 4);
        }
        if (Input.GetButtonDown("Melee") && !attacking && !isGunLoading)
        {
            Attack();
        }
        if (Input.GetButtonDown("Ranged") && !attacking && !isGunLoading && onGround)
        {
            Shoot();
        }

        if (Input.GetButtonDown("Dash") && !attacking && !isGunLoading && onGround)
        {
            dashController.DashTo(facingRight? Dash.RIGHT : Dash.LEFT);
        }


        if (isGunLoaded)
        {
            idleGunTime += Time.deltaTime;
            if (idleGunTime >= unloadWaitingTime)
            {
                UnloadGun();
            }
        }
    }