Exemple #1
0
        public override void OnTriggerEnter2D(Collider2D collider)
        {
            base.OnTriggerEnter2D(collider);

            if (collider.gameObject.tag == "Enemy")                           //if contact with enemy
            {
                AIStats enemy = collider.gameObject.GetComponent <AIStats>(); //get aistats component
                Damage(enemy);                                                //damage enemy
            }
        }
Exemple #2
0
 private void Start()
 {
     aiStats = GetComponent <AIStats>();
 }
Exemple #3
0
 private void Start()
 {
     aIStats = GetComponentInParent <AIStats>();
     UpdateUI();
 }
Exemple #4
0
 //Damage method
 void Damage(AIStats enemy)
 {
     enemy.TakingDamage(damageRange.RandomFloat()); //Random damage between damageRange.min and max
     Destroying();
 }