void Update() { //Debug.Log(BroomPosition); if (SwitchSnap.GetCurrentSnappedObject() != null) { if (SwitchSnap.GetCurrentSnappedObject().CompareTag("JanitorBroom") && notWaited) { Debug.Log("entered"); foreach (JanitorBroomTransformer rend in SwitchSnap.GetCurrentSnappedObject().transform.GetChild(0).GetComponentsInChildren <JanitorBroomTransformer>()) { if (rend.changeBroomColour) { metallicBroomParts++; if (notWaited && metallicBroomParts == 8) //needs whole broom to be metallic to work { SwitchAnim.SetBool("Crack", true); BroomOpensLockerSound.Play(); notWaited = false; foreach (MeshRenderer child in SwitchSnap.GetCurrentSnappedInteractableObject().transform.GetChild(0).GetComponentsInChildren <MeshRenderer>()) { child.enabled = false; } GameObject.Find("Switch_box").GetComponent <VRTK_PhysicsRotator>().isLocked = false; GetComponent <VRTK_PhysicsRotator>().angleLimits = new Limits2D(25f, -90f); foreach (Collider child in SwitchSnap.GetCurrentSnappedInteractableObject().transform.GetChild(0).GetComponentsInChildren <Collider>()) { child.enabled = false; } metallicBroom = true; Debug.Log("crackLock"); StartCoroutine("MetallicBroomOpensLocker"); //waits for the animation of broom opening the locker to finish, then moves the broom which was snapped to that position break; } } else { continue; } } if (!metallicBroom) { metallicBroomParts = 0; notWaited = false; SwitchAnim.SetBool("Break", true); foreach (MeshRenderer child in SwitchSnap.GetCurrentSnappedInteractableObject().transform.GetChild(0).GetComponentsInChildren <MeshRenderer>()) { child.enabled = false; } GetComponent <VRTK_PhysicsRotator>().angleLimits = new Limits2D(25f, -90f); foreach (Collider child in SwitchSnap.GetCurrentSnappedInteractableObject().transform.GetChild(0).GetComponentsInChildren <Collider>()) { child.enabled = false; } StartCoroutine("BroomBreaks"); Debug.Log("BrokenBroom"); } } } }