public void OnCollisionEnter(Collision coll) { // If this is the child of another Asteroid, pass this collision up the chain if (parentIsAsteroid) { parentAsteroid.OnCollisionEnter(coll); return; } if (immune) { return; } GameObject otherGO = coll.gameObject; if (otherGO.tag == "Bullet" || otherGO.transform.root.gameObject.tag == "Player") { if (otherGO.tag == "Bullet") { GameManager.score += GameManager.AsteroidsSO.pointsForAsteroidSize[size]; if (GameManager.score >= AchievementManager.scoreToReachRookiePilot && !AchievementManager.S.Achievements[3].complete) { GameManager.HIGH_SCORE_DELEGATE(); } if (!GameManager.getHighScore && SaveGameManager.CheckHighScore(GameManager.score)) { GameManager.HIGH_SCORE_DELEGATE(); GameManager.getHighScore = true; } Bullet.BULLET_HIT_ASTEROID_DELEGATE(); if (otherGO.GetComponent <Bullet>().bDidWrap == true) { Bullet.LUCKY_SHOT_DELEGATE(); } Destroy(otherGO); } if (size > 1) { // Detach the children Asteroids Asteroid[] children = GetComponentsInChildren <Asteroid>(); for (int i = 0; i < children.Length; i++) { children[i].immune = true; if (children[i] == this || children[i].transform.parent != transform) { continue; } children[i].transform.SetParent(null, true); children[i].InitAsteroidParent(); } } int index = Random.Range(0, 2); GameObject go = GameManager.AsteroidsSO.asteroidExplosionPrefabs[index]; go.transform.localScale = gameObject.transform.localScale; ParticleSystem particleSys = go.GetComponent <ParticleSystem>(); ParticleSystem.MainModule main = particleSys.main; main.startSpeedMultiplier = 5 / gameObject.transform.localScale.x; Instantiate(go, transform.position, Quaternion.identity); Destroy(gameObject); } }