Exemple #1
0
 void OnTriggerEnter(Collider c)
 {
     if (c == player)
     {
         door.Open();
     }
 }
Exemple #2
0
    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;
            }
        }
    }
Exemple #3
0
 public void Open()
 {
     foreach (Transform child in transform)
     {
         GameObject  childObject = child.gameObject;
         SlidingDoor childScript = childObject.GetComponent <SlidingDoor>();
         childScript.Open();
     }
 }