// Update is called once per frame void Update() { if (combatLock && InRange()) { agent.enabled = false; if (attack != null && attack.Attack()) { if (tag == "VjsMamma") { Debug.Log("Attacking2"); } enemy.GetComponent <BaseUnit>().TakeDamage(attack.TotalAttackDamage); if (enemy.GetComponent <BaseUnit>().health.IsDead()) { ExitCombatLock(); } } } else if (combatLock && chase != null) { chase.ChangeTarget(enemy.transform.position); } if (health.IsDead()) { Destroy(gameObject); } }