// Use this for initialization void Start() { bh = GetComponent <buildingHealth>(); if (bh == null) { Destroy(this); } hp = bh.MaxHP; }
// Update is called once per frame private void OnTriggerEnter(Collider other) { print("OnTriggerEnter"); if (!isAttacking) { target = other.GetComponent <buildingHealth>(); if (target != null) { GetComponent <NavMeshAgent>().isStopped = true; isAttacking = true; InvokeRepeating("prepareAttack", 0, 0.5f); InvokeRepeating("Attack", 0.1f, 0.5f); } } }