public void DetachFoot() { leg.DetachLeg(); attached = false; attachable = false; body.attachedLegs.Remove(this); attachmentPointJoint.enabled = false; //attachmentPointJoint.autoConfigureDistance = true; //attachmentPointJoint.frequency = 1; attachmentPoint = null; if (attachmentPointJoint.connectedBody != null) { attachmentPointJoint.connectedBody = null; } //attachmentPointJoint = null; //fixedJoint.enabled = false; // Put arm back on default layer Transform[] _children = GetComponentsInChildren <Transform>(); foreach (Transform child in _children) { child.gameObject.layer = 9; } // start attach cooldown to prevent instant re attachment. StartCoroutine(DetachCooldown()); // play sound string randomRipSound = "Rip_" + Random.Range(1, 3).ToString(); AudioManager.instance.Play(randomRipSound); AudioManager.instance.ChangePitch(randomRipSound, Random.Range(0.7f, 1.3f)); Debug.Log("Foot detached"); }