public void SetDamage(InfoBulletCollision info) { if (Hp > 0) { GetComponent <Animator>().Play("damage_001"); Hp -= info.Damage; } if (Hp <= 0) { _isDeath = true; _agent.enabled = false; GetComponent <Animator>().Play("dead"); Destroy(this.gameObject, 10); } }
public void SetDamage(InfoBulletCollision info) { if (HP > 0) { HP -= info.Damage; } if (HP <= 0) { HP = 0; Color = Color.red; var tempRB = GetComponent <Rigidbody>(); if (!tempRB) { tempRB = gameObject.AddComponent <Rigidbody>(); } tempRB.AddForce(info.Dir * force); Destroy(gameObject, destroyTime); } }