void OnJointBreak(float breakForce) { navigator.StopTracking(); headAttached = false; GameObject head = fixedJoint.connectedBody.gameObject; ShrinkAndDestroy headShrink = head.AddComponent <ShrinkAndDestroy> (); headShrink.explosion = headExplosion; headShrink.rate = 0.25f + Random.value * 0.1f; headShrink.toDestroy = transform.parent.gameObject; ShrinkAndDestroy bodyShrink = gameObject.AddComponent <ShrinkAndDestroy> (); bodyShrink.explosion = bodyExplosion; bodyShrink.rate = 0.75f + Random.value * 0.1f; }
/// <summary> /// Destroy all currently up walls /// </summary> private void DestroyAllWalls(bool playSound) { // Let shit fly if (GameObject.Find("GYM") != null) { Transform st = GameObject.Find("GYM").transform.Find("SquatTrack"); st.Find("SquatBars").GetComponent <GuideRail>().PauseBoxCols(); } // Get all the wall gibs GameObject[] gibsGO = GameObject.FindGameObjectsWithTag("Gibs"); // Loop through all the gibs for (int x = 0; x < gibsGO.Length; x++) { Rigidbody gibs = gibsGO[x].GetComponent <Rigidbody>(); // Get the rigid body if (gibs.GetComponent <GibControl>().BlowUpGib == true) { if (gibs.transform.parent != null && gibs.transform.parent.parent != null) { Transform t = gibs.transform.parent.parent; // Get the grandparent (Squat-Wall) gibs.GetComponent <MeshRenderer>().enabled = true; // Make it so the player can see the gibs ShrinkAndDestroy shrinkAndDestroy = gibs.gameObject.GetComponent <ShrinkAndDestroy>(); shrinkAndDestroy.ShrinkDestroy(10); gibs.transform.parent = null; // Un-parent the gibs gibs.isKinematic = false; // Make physics work on them gibs.AddForce(new Vector3(Random.Range(-750, 750), Random.Range(750, 1000), Random.Range(-300, 300))); // Add random force gibs.AddTorque(new Vector3(Random.Range(-100, 100), Random.Range(100, 100), Random.Range(-100, 100))); // Add random torque Destroy(t.gameObject); // Destroy the squat wall } } } // Make sound if (gameStarted == true) { wallSoundEffects.PlayClip(WallSoundEffects.WallSoundEffectClip.fail); } }
private void Awake() { myCollider = GetComponentInChildren <Collider>(); terminator = GetComponent <ShrinkAndDestroy>(); }