void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Player1" || other.gameObject.tag == "Player2" || other.gameObject.tag == "Enemy") { PawnData pawn = other.gameObject.GetComponent <PawnData>(); if ((pawn.gameObject.tag == "Player1" && playerData.gameObject.tag == "Enemy") || (pawn.gameObject.tag == "Player2" && playerData.gameObject.tag == "Enemy")) { pawn.health -= playerData.damage; if (pawn.health <= 0) { playerDeathAudio.Play(); pawn.lives--; livesKeeper.AddLives(pawn.lives, pawn); other.gameObject.SetActive(false); GameManager.instance.RespawnPlayer(other.gameObject); if (pawn.lives <= 0) { pawn.GameOver(pawn.gameObject); } } } if ((pawn.gameObject.tag == "Enemy" && playerData.gameObject.tag == "Player1") || (pawn.gameObject.tag == "Enemy" && playerData.gameObject.tag == "Player2")) { pawn.health -= playerData.damage; if (pawn.health <= 0) { enemyDeathAudio.Play(); GameManager.instance.Enemies.Remove(pawn.gameObject); Destroy(pawn.gameObject); playerData.score++; scoreKeeper.AddScore(playerData, playerData.score); } } } bulletAudio.Play(); Destroy(gameObject); }