// Update is called once per frame void Update() { m_enemyHealthbarFill.fillAmount = enemyHealth / enemyMaxHealth; if (enemyHealth <= 0 && !m_isDead) { m_enemyHealthbar.gameObject.SetActive(false); GetComponent <BoxCollider2D>().enabled = false; m_body2d.simulated = false; m_animator.SetTrigger("Dead"); m_isDead = true; } else if (!m_isDead) { //m_wantedPos = m_camera.WorldToViewportPoint(new Vector2(transform.position.x, transform.position.y + 50)); //m_enemyHealthbar.position = m_wantedPos; if (!m_grounded && m_groundSensor.State()) { m_grounded = true; } //Check if character just started falling if (m_grounded && !m_groundSensor.State()) { m_grounded = false; } if (m_grounded) { LookForPlayer(); //Checks if Player is in melee, if they are then attack, if not then move if (m_inMelee && Time.time > m_attackWait + lastAttack && m_player.GetComponent <PlayerStats>().health > 0) { Attack(); lastAttack = Time.time; } else { Move(); } } } //if (!m_animator.GetCurrentAnimatorStateInfo(0).IsTag("Attack")) //{ // float inputX = Input.GetAxis("Horizontal"); // //Run // if (Mathf.Abs(inputX) > Mathf.Epsilon) // m_animator.SetInteger("Speed", (int)m_body2d.velocity.magnitude); //} }