// Update is called once per frame
    void Update()
    {
        if (off)
        {
            return;
        }

        timer -= Time.deltaTime;
        Vector3 dir = target.position - transform.position;

        dir.z = 0.0f;
        if (dir != Vector3.zero)
        {
            float move = target.position.x > transform.position.x ? 1:-1;
            enemyFlip.FlipInAttack(move);
        }

        if (Vector3.Distance(target.position, transform.position) > 3)
        {
            anim.SetWalk();
            Vector3 Direction    = (target.position - transform.position).normalized;
            Vector3 NewDirection = new Vector3(Direction.x, 0, 0);
            transform.position += NewDirection * moveSpeed * Time.deltaTime;
        }

        if (Vector3.Distance(target.position, transform.position) < AttackDistance && timer < 0)
        {
            anim.SetAttack();
            Fire();
        }
    }