sorry to bother again but how can i get one door to open when i click it beacuse now all doors open when i try to open just one 
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DoorOpen : MonoBehaviour
{
public GameObject Playerr;
public PlayerRay playerray;
public Vector3 AfterAngles;
public Animator animator;
public Vector3 CurrentAngles;
public GameObject Door;
public float x;
public float y;
public float z;
public float x1;
public float y1;
public float z1;
public bool DoorIsOpen = false;
public bool DoorIsClosed = true;
public bool PlayerIsNear = false;
public Text InfoText;
public GameObject TextParent;
public void Start()
{
playerray = Playerr.GetComponent<PlayerRay>();
TextParent.SetActive(false);
Door = this.gameObject;
animator = GetComponent<Animator>();
}
public void Update()
{
if (Input.GetKeyDown(KeyCode.E) && DoorIsOpen == false && PlayerIsNear == true)
{
animator.SetTrigger("OpenDoor");
x = CurrentAngles.x;
y = CurrentAngles.y;
z = CurrentAngles.z;
Door.GetComponent<Transform>().eulerAngles = CurrentAngles;
Door.GetComponent<Transform>().eulerAngles.Set(x, y -= 90, z);
Door.GetComponent<Transform>().eulerAngles = AfterAngles;
x1 = AfterAngles.x;
y1 = AfterAngles.y;
z1 = AfterAngles.z;
}
if (Input.GetKeyDown(KeyCode.E) && DoorIsOpen == true && PlayerIsNear == true)
{
animator.SetTrigger("CloseDoor");
x = CurrentAngles.x;
y = CurrentAngles.y;
z = CurrentAngles.z;
Door.GetComponent<Transform>().eulerAngles = CurrentAngles;
Door.GetComponent<Transform>().eulerAngles.Set(x, y += 90, z);
Door.GetComponent<Transform>().eulerAngles = AfterAngles;
x1 = AfterAngles.x;
y1 = AfterAngles.y;
z1 = AfterAngles.z;
}
if (playerray.IsOpen == true)
{
//Debug.Log("we hit" + hit.collider.name + " " + hit.point);
rayopen();
}
else
{
rayclose();
}
}
public void open()
{
DoorIsOpen = true;
DoorIsClosed = false;
}
public void close()
{
DoorIsOpen = false;
DoorIsClosed = true;
}
public void rayopen()
{
TextParent.SetActive(true);
this.gameObject.GetComponentInChildren<DoorOpen>(PlayerIsNear = true);
Debug.Log("welcome");
InfoText.text = ("press E");
}
public void rayclose()
{
this.gameObject.GetComponentInChildren<DoorOpen>(PlayerIsNear = false);
TextParent.SetActive(false);
}
}
C#:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerRay : MonoBehaviour
{
public bool IsOpen;
public GameObject DoorParent;
public DoorOpen dooropen;
public LayerMask door;
public GameObject ThisDoor;
Camera cam;
void Start()
{
ThisDoor = DoorParent.GetComponentInChildren<DoorOpen>().Door;
dooropen = DoorParent.GetComponentInChildren<DoorOpen>();
cam = Camera.main;
}
// Update is called once per frame
void Update()
{
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 5, door))
{
Debug.Log("we hit" + hit.collider.name + " " + hit.point);
IsOpen = true;
}
else
{
IsOpen = false;
}
}
}
Last edited: