void Update()
    {
        tempIdleTime   -= Time.deltaTime;
        tempRunTime    -= Time.deltaTime;
        tempAttackTime -= Time.deltaTime;
        tempHitTime    -= Time.deltaTime;
        tempSleepTime  -= Time.deltaTime;

        if (isHit)
        {
            visionRange = visionRange2;
        }

        float distance = Vector3.Distance(target.position, transform.position);

        if ((health.HealthPoint <= 0 || sedat.SedatPoints <= 0) && !GetComponent <GatherSyringe>().gathered)
        {
            health.OnDead();
            isDead = true;
        }
        else if (sedat.SedatPoints <= 0 && !isDied)
        {
            isSleep = true;
        }
        else if (HitPlayer())
        {
            isInAtk = true;
        }
        else if (distance < visionRange)
        {
            visionRange = visionRange2;
            isInRange   = true;
        }

        if (distance > visionRange)
        {
            isInRange = false;
        }
        else if (!HitPlayer())
        {
            isInAtk = false;
        }

        if (isDied)
        {
            agent.SetDestination(transform.position);
            anim.SetBool("isAttacking", false);
            anim.SetBool("isRunning", false);

            anim.SetBool("isIdling", true);
            anim.SetBool("isDead", true);

            anim.Play("Died");
        }
        else if (isDead)
        {
            agent.SetDestination(transform.position);
            anim.SetBool("isAttacking", false);
            anim.SetBool("isRunning", false);

            anim.SetBool("isIdling", true);
            anim.SetBool("isDead", true);
            anim.Play("Death");
        }
        else if (isSleep)
        {
            agent.SetDestination(transform.position);
            anim.SetBool("isAttacking", false);
            anim.SetBool("isRunning", false);

            anim.SetBool("isIdling", true);
            anim.SetBool("isDead", true);
            anim.Play("Death");
        }

        // roar 4
        else if (health.HealthPoint <= 0.2f * health.MaxHealthPoint && firstTimeRoar04)
        {
            print("lower than 25%");
            ws.SpawnWave04();

            agent.SetDestination(transform.position);
            anim.SetBool("isRunning", false);
            anim.SetBool("isIdling", false);
            anim.SetBool("isRoaring", true);
            anim.SetBool("isAttacking", false);

            Invoke("StopPlayRoar04", 4.9f);
        }

        // roar 3
        else if (health.HealthPoint <= 0.4f * health.MaxHealthPoint && firstTimeRoar03)
        {
            print("lower than 50%");
            ws.SpawnWave03();

            agent.SetDestination(transform.position);
            anim.SetBool("isRunning", false);
            anim.SetBool("isIdling", false);
            anim.SetBool("isRoaring", true);
            anim.SetBool("isAttacking", false);

            Invoke("StopPlayRoar03", 4.9f);
        }

        // roar 2
        else if (health.HealthPoint <= 0.6f * health.MaxHealthPoint && firstTimeRoar02)
        {
            print("lower than 75%");
            ws.SpawnWave02();

            agent.SetDestination(transform.position);
            anim.SetBool("isRunning", false);
            anim.SetBool("isIdling", false);
            anim.SetBool("isRoaring", true);
            anim.SetBool("isAttacking", false);

            Invoke("StopPlayRoar02", 4.9f);
        }
        else if (health.HealthPoint <= 0.80f * health.MaxHealthPoint && firstTimeRoar02)
        {
            ws.SpawnWave01();
        }

        else if (isAttacking)
        {
            agent.SetDestination(transform.position);
            if (tempAttackTime <= 0)
            {
                Attack();
            }
        }
        else if (isInAtk)
        {
            agent.SetDestination(transform.position);
            anim.SetBool("isRunning", false);
            anim.SetBool("isIdling", false);

            anim.SetBool("isAttacking", true);
            anim.Play("Attack");
        }
        else if (isInRange)
        {
            if (firstTimeSeen)
            {
                agent.SetDestination(transform.position);
                anim.SetBool("isRunning", false);
                anim.SetBool("isIdling", false);
                anim.SetBool("isRoaring", true);
                anim.Play("Roar");

                Invoke("StopPlayRoar01", 4.9f);
            }
            else
            {
                agent.SetDestination(target.position);
                anim.SetBool("isIdling", false);
                anim.SetBool("isAttacking", false);

                anim.SetBool("isRunning", true);
                if (tempRunTime <= 0)
                {
                    PlayRunSound(audioSource);
                    tempRunTime = 0.8f;
                }
            }
        }
        else if (!isInAtk && !isInRange)
        {
            agent.SetDestination(transform.position);
            anim.SetBool("isRunning", false);
            anim.SetBool("isAttacking", false);

            anim.SetBool("isIdling", true);
            if (tempIdleTime <= 0)
            {
                PlayIdleSound(audioSource);
                tempIdleTime = 5f;
            }
        }
        else
        {
            isInRange = false;
        }

        if (isDeadDrop && !isDroped)
        {
            PlayDeadDropSound(audioSource);
            isDroped = true;
        }

        if (isRoaring)
        {
            PlayRoarSound(audioSource);
        }
        if (health.HealthPoint <= 0 || sedat.SedatPoints <= 0)
        {
            GetComponent <GatherSyringe>().ShowUI(textPrefab);
        }
    }