private void Update() { if (IsLifeSpanOver()) { gameObject.SetActive(false); _gun.AddToPool(this); } }
private void OnCollisionEnter(Collision collision) { gameObject.SetActive(false); _gun.AddToPool(this); var enemy = collision.gameObject.GetComponent <Enemy>(); if (enemy) { enemy.TakeDamage(collision.contacts[0].point); } }
public void OnCollisionEnter(Collision collision) { gameObject.SetActive(false); _gun?.AddToPool(this); var enemy = collision.collider.GetComponent <Enemy>(); if (enemy != null) { int playerNumber = _gun.GetComponent <Player>().PlayerNumber; enemy.TakeDamage(collision.contacts[0].point, playerNumber); } }