Door Opening Script isn't working.

Hi there,

Admittedly, I’m an artist, not a programmer, but I had a game made with some help from a programmer previously. I took a script I used for opening a door in my project from a year ago and adapted it to my current project. However, while I am able to make the parameters work, since I’m able to get the open variable to turn false and true on trigger, I can’t seem to get the door I’m applying the script on to open. Furthermore, oddly enough, there are random select times when the game will freeze for a moment and the door will just appear open when I get near it. I can’t control if or when that happens. I’m very confused and would like some help. Here’s the script.

using UnityEngine;
using System.Collections;

public class DoorOpenScript : MonoBehaviour {

	public float smooth = 3.50f;
	public float DoorOpenAngle = 90.0f;
	public bool open;
	//public bool opening = false;
	private bool enter;
	public Quaternion defaultRot;
	private Quaternion openRot;

	
	public GameObject CameraMarker;
	public Vector3 CamPosition;
	public bool spawnOnce = false;
	public AudioClip openEffect;
	
	//GUI Door Prompt Parameters
	public int buttonW = 120;
	public int buttonH = 45;

	public int GUIPromptCentre = 56;

	
	private bool unused = false;
	
	// Use this for initialization
	void Start ()
	{	

		defaultRot = transform.rotation;
		openRot = Quaternion.Euler (new Vector3 (defaultRot.eulerAngles.x,
		                                         defaultRot.eulerAngles.y + DoorOpenAngle, defaultRot.eulerAngles.z));
		open = false;
		
	}
	
	// Update is called once per frame
	void Update () 
	{

		if (open == true) {
			//Open door
			transform.rotation = Quaternion.Slerp (transform.rotation, openRot, Time.deltaTime * smooth);
			open = true;
			
		} if(open == false) {
			//Close door
			transform.rotation = Quaternion.Slerp (transform.rotation, defaultRot, Time.deltaTime * smooth);
		}
		

	}
	
	void OnGUI ()
	{
		
		if (enter == true){
			GUI.Button (new Rect (Screen.width/2, Screen.height/2, buttonW, buttonH), 
			            "Test");
		}
	}
	
	//Activate the Main function when player is near the door
	void OnTriggerEnter (Collider other)
	{
		if (other.gameObject.tag == "Player") {
			enter = true;

		}
		
	}
	
	//Deactivate the Main function when player is go away from door
	void OnTriggerExit (Collider other)
	{
		if (other.gameObject.tag == "Player") {
			enter = false;
		}
	}
	
	
}

The variable ‘enter’ is set true/false in your trigger functions. While it is the open bool that is being tested in Update(). Change open to enter in Update().

Unless you are looking for the button to be pressed to open the door, then change the OnGUI() to:

if(enter)
{
if(GUI.Button(#parameters#))
{
open = true;
}
}