void OnTriggerEnter(Collider c) { if (c == player) { door.Open(); } }
private void OnCollisionEnter(Collision other) { // Stop when no locked object is defined if (!lockedObject) { return; } // Stop when no there is no rigidbody if (!other.gameObject.GetComponent <Rigidbody>()) { return; } // Add mass currentMass += other.gameObject.GetComponent <Rigidbody>().mass; // Check mass difference if (currentMass >= minimalMass) { //Debug.Log("Open the door"); door.Open(3f); // Remove the lock if must not hold if (!mustHold) { door.LockedWithSwitch = false; } } }
public void Open() { foreach (Transform child in transform) { GameObject childObject = child.gameObject; SlidingDoor childScript = childObject.GetComponent <SlidingDoor>(); childScript.Open(); } }