title: Unity 3D Door Script
body: <p>I have written a door script for big vault doors.
  My problem is the following: if I assign the script to more than one door
  in the scene, all doors open and close together at the same time
  that one of them is touched.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class BigDoorScript : MonoBehaviour
  {
  
      private bool doorOpen = false;
      private Ray ray;
      private RaycastHit hit;
      private float distance = 5.0f;
      public GameObject door;
  
      private void Update()
      {
          if (Input.GetKeyDown("e"))
          {
              ray = Camera.main.ScreenPointToRay(Input.mousePosition);
              if (Physics.Raycast(ray, out hit, distance))
              {
                  if (!doorOpen)
                  {
                      door.transform.Translate(new Vector3(0.0f, 0.0f, 4.0f));
                      doorOpen = true;
                  }
                  else
                  {
                      door.transform.Translate(new Vector3(0.0f, 0.0f, -4.0f));
                      doorOpen = false;
                  }
              }
          }
      }
  }
  </code></pre>