/// <summary> /// Метод "Получение урона". /// </summary> /// <param name="info">от "чьей" руки</param> public void SetDamage(InfoCollision info) { Hp -= info.Damage; if (Hp <= 0) { IsDeath = true; Death(info); } }
/// <summary> /// Метод "Смерть". /// </summary> /// <param name="info">от "чьей" руки</param> private void Death(InfoCollision info) { foreach (Transform child in transform) { if (!Rigidbody) { child.gameObject.AddComponent <Rigidbody>(); } child.parent = null; Rigidbody.AddForceAtPosition(info.Dir * 10, info.Hit.point); } }