Hey everyone. Thanks for the help! I’ve couldn’t have done it without you.
EETechnology: thanks for taking your time man
it helped
BoredMormon: PS I’m attending mechatronics, in which they don’t teach this sorts of stuff, rather robots, machines, CNC,CAD… I’m making an exclusive final year project for my graduation. Everyone in my program is making these tiny robots, 3D printers… I’m making a project in Unity and if you open a door in Unity, the door opens in real life; if you lit a light, the light lits in real life…
lordconstant: hey thanks for the information and the code! I used it in mine and it works 
Here is the code:
using UnityEngine;
using System.Collections;
public class SlidingDoorScript : MonoBehaviour {
public Vector3 desiredPosition; //the position/coordinates to move the door to
public Vector3 defaultPosition; //the default position/coordinates of the door
public float speed = 0.3f; //the speed of the opening/closing
private bool firstOpen = false; //var determening if the door has been opened at least once
private bool open; //is the door open or not?
private bool enter; //has the player entered the triggering volumes?
private float prog; //for calculating path, the door has traveled
void OnGUI() //GUI text
{
GUIStyle myStyle = new GUIStyle(GUI.skin.GetStyle("label"));
myStyle.fontSize = 25;
if (enter == true) {
if (open == false) {
GUI.Label (new Rect (Screen.width / 2 - 75, Screen.height - 300, 150, 50), "E - open",myStyle);
} else {
GUI.Label (new Rect (Screen.width / 2 - 75, Screen.height - 300, 150, 50), "E - close",myStyle);
}
}
}
void OnTriggerEnter(){
enter = true;
}
void OnTriggerExit(){
enter = false;
}
void Update()
{
if (enter) {
if (open) {
prog = Path (speed);
transform.position = Vector3.Lerp(defaultPosition,desiredPosition, prog); //moves door to desiredPos
}
if (!open){
prog = Path (speed);
if (firstOpen){ //if the door has been opened at least once (this prevents the door from moving to desired position on start)
transform.position = Vector3.Lerp(desiredPosition,defaultPosition, prog); //moves door to desiredPos
}
if (transform.position != desiredPosition){ //if on start the door is not on desired position...
transform.position = Vector3.Lerp (defaultPosition, transform.position, 1); //...move it to desired position
}
}
if (Input.GetKeyDown("e")){ //on e-pressed toggle bool open
open = !open;
firstOpen = true; //door has been opened once
prog = 0.00f; //reset path for next opening/closing
}
}else if (!enter) //this if is to ensure that, if the player is outside the triggering, then finish closing/opening the door without stoping
{
if (open) {
prog = Path (speed);
transform.position = Vector3.Lerp(defaultPosition,desiredPosition, prog); //moves door to desiredPos
}
if (!open){
prog = Path (speed);
if (firstOpen){ //if the door has been opened at least once (this prevents the door from moving to desired position on start)
transform.position = Vector3.Lerp(desiredPosition,defaultPosition, prog); //moves door to desiredPos
}
}
if (transform.position != desiredPosition){ //if on start the door is not on desired position...
transform.position = Vector3.Lerp (defaultPosition, transform.position, 1); //...move it to desired position
}
}
}
//smoothly calculating path
float Path (float speed)
{
prog += Time.deltaTime * speed;
if (prog >= 1) {
prog = 1.0f;
}
return prog;
}
}
This works even if the door is rotated and has normal-space coordinates, not global.