private void OnTriggerEnter(Collider other) { if (other.GetComponent <Health1>() != target) { return; } if (target.IsDead()) { return; } target.TakeDamage(instigator, damage); speed = 0; if (hitEffect != null) { Instantiate(hitEffect, GetAimLocation(), transform.rotation); } foreach (GameObject toDestroy in destroyOnHit) { Destroy(toDestroy); } Destroy(gameObject, lifeAfterImpact); }
void Attack() { // Reset the timer. timer = 0f; audio.Play(); // If the player has health to lose... anim.SetTrigger("Attack"); // ... damage the player. playerHealth.TakeDamage(attackDamage); // If the player has zero or less health... if (playerHealth.currentHealth <= 0) { Destroy(player); anim.ResetTrigger("Attack"); audio.Stop(); } }
void OnTriggerEnter(Collider vOther) { Health1 tH = vOther.GetComponent <Health1> (); if (tH != null) { Destroy(gameObject); tH.TakeDamage(15); // CmdHit (tNID.netId); } Enemy tE = vOther.GetComponent <Enemy> (); if (tE != null) { tE.NewColour(Random.ColorHSV()); } }
// Animation Event void Hit() { if (target == null) { return; } float damage = GetComponent <BaseStats>().GetStat(Stat.Damage); if (currentWeapon.value.HasProjectile()) { currentWeapon.value.LaunchProjectile(rightHandTransform, leftHandTransform, target, gameObject, damage); } else { target.TakeDamage(gameObject, damage); } }