Files
BABA_YAGA/Assets/TEST CUA TUAN/Free Wood Door Pack/Script/CameraOpenDoor.cs

32 lines
706 B
C#
Raw Normal View History

2026-04-01 02:41:07 +07:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace CameraDoorScript
{
public class CameraOpenDoor : MonoBehaviour {
public float DistanceOpen=3;
public GameObject text;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
RaycastHit hit;
if (Physics.Raycast (transform.position, transform.forward, out hit, DistanceOpen)) {
if (hit.transform.GetComponent<DoorScript.Door> ()) {
text.SetActive (true);
if (Input.GetKeyDown(KeyCode.E))
hit.transform.GetComponent<DoorScript.Door> ().OpenDoor();
}else{
text.SetActive (false);
}
}else{
text.SetActive (false);
}
}
}
}