void createExplosion() { ExplosionBlocks.SetActive(true); ExplosionBlocks.transform.position = this.transform.position; ExplosionBlocks.transform.rotation = this.transform.rotation; foreach (Transform transform in ExplosionBlocks.GetComponentInChildren <Transform>(true)) { if (transform.gameObject.GetComponent <Rigidbody>()) { if (!switchedCameraFollow) { cameraScript.SwitchTargets(transform); switchedCameraFollow = true; } transform.gameObject.GetComponent <Rigidbody>().angularVelocity = new Vector3(r.Next(-100, 100), r.Next(-100, 100), r.Next(-100, 100)); transform.gameObject.GetComponent <Rigidbody>().velocity = mWall.gameObject.GetComponent <Rigidbody>().velocity; } } }