void OnTriggerExit(Collider c) { if (c == player) { door.Close(); } }
private void OnCollisionExit(Collision other) { // Stop if the player doesn't have to hold the button if (!mustHold) { return; } // Stop when no locked object is defined if (!lockedObject) { return; } // Stop when no there is no rigidbody if (!other.gameObject.GetComponent <Rigidbody>()) { return; } // Remove mass currentMass -= other.gameObject.GetComponent <Rigidbody>().mass; // Check mass difference if (currentMass < minimalMass) { //Debug.Log("Lock the door"); door.Close(); } }
public void Close() { foreach (Transform child in transform) { GameObject childObject = child.gameObject; SlidingDoor childScript = childObject.GetComponent <SlidingDoor>(); childScript.Close(); } }