void Boom() { // Fix our angle and stop moving rigidbody2D.velocity = Vector2.zero; rigidbody2D.fixedAngle = true; rigidbody2D.isKinematic = true; // Explode ourselves animator.SetBool("Exploded", true); // Set spawner to stop spawning GameObject[] spawners = GameObject.FindGameObjectsWithTag("Respawn"); for (int i = 0; i < spawners.Length; i++) { ObstacleSpawner os = spawners[i].GetComponent <ObstacleSpawner>(); if (os != null) { os.IsSpawning = false; } MountainSpawner ms = spawners[i].GetComponent <MountainSpawner>(); if (ms != null) { ms.IsSpawning = false; } } // Stop moving Obstacles GameObject[] Obstacles = GameObject.FindGameObjectsWithTag("Obstacle"); for (int i = 0; i < Obstacles.Length; i++) { ObstacleBehavior ob = Obstacles[i].GetComponent <ObstacleBehavior>(); if (ob != null) { ob.speed = 0; } } // Set ourselves as exploded hasExploded = true; // Stop clouds GameObject particles = GameObject.FindGameObjectWithTag("Particles"); if (particles != null) { particles.GetComponent <ParticleSystem>().Pause(); } // Stop mountains GameObject[] Mountains = GameObject.FindGameObjectsWithTag("Mountains"); for (int i = 0; i < Mountains.Length; i++) { MountainBehavior ob = Mountains[i].GetComponent <MountainBehavior>(); if (ob != null) { ob.BaseSpeed = 0; } } // Stop Music GameObject music = GameObject.FindGameObjectWithTag("Music"); if (music != null) { music.GetComponent <AudioSource>().Stop(); Destroy(music); } // Flash the screen flasher.StartFlash(); // Play Explosion Sound audio.clip = explode; audio.Play(); // Show menu GameObject.FindGameObjectWithTag("RestartMenu").GetComponent <RestartMenu>().Show(); }