コード例 #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Attacker")
     {
         AttackerHealth attackerHealth = other.GetComponent <AttackerHealth>();
         if (attackerHealth != null)
         {
             attackerHealth.DealDamage();
             Destroy(gameObject);
         }
     }
 }
コード例 #2
0
    public void strikeCurrentInvader(float damage)
    {
        if (!currentInvaderTarget)
        {
            return;
        }

        AttackerHealth health = currentInvaderTarget.GetComponent <AttackerHealth>();

        if (health)
        {
            health.DealDamage(damage);
        }
    }
コード例 #3
0
ファイル: Attacker.cs プロジェクト: AcePilot10/Car-Game
 private void Awake()
 {
     rb     = GetComponent <Rigidbody2D>();
     health = GetComponent <AttackerHealth>();
 }