コード例 #1
0
ファイル: Weapon.cs プロジェクト: gallobonts/portfolio
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (canAttack && other.transform.tag == "monster")
     {
         monsterAI script = (monsterAI)other.transform.GetComponent(typeof(monsterAI));
         script.TakeDamage(damage);
         canAttack = false;
     }
 }
コード例 #2
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.transform.tag == "monster")
     {
         monsterAI script = (monsterAI)other.transform.GetComponent(typeof(monsterAI));
         script.TakeDamage(damage);
         myGameObject.SetActive(false);
     }
     else if (other.transform.tag == "obstacle")
     {
         myGameObject.SetActive(false);
     }
 }