private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Bullet")) { health--; Destroy(collision.gameObject); if (health == 0) { AudioManager.Play(DeadAudio); Director.AddToScore(ScoreValue); Instantiate(ExplosionPrefab, transform.position, Quaternion.identity); if (StaticLibrary.RandomBool(PickupChance)) { PickupManager.PlaceRandomPickup(transform.position); } else { Vector3 position = GameObject.Find("Camera").GetComponent <Camera>().WorldToScreenPoint(transform.position); GameObject points = Instantiate(TextPrefab, position, Quaternion.identity, GameObject.Find("Canvas").transform); points.GetComponent <Text>().text = "" + ScoreValue; Destroy(points, 2f); } Destroy(gameObject); } else { AudioManager.Play(HitAudio); UpdateColour(); } } }