using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class TigerInteraction : MonoBehaviour { private Camera cam; [SerializeField] private float distance = 5f; [SerializeField] private LayerMask mask; private PlayerUI playerUI; public GameObject tiger; public GameObject maincam, gamecam; public bool GameState = true; // Start is called before the first frame update void Start() { cam = GetComponent().m_fpsCamera; playerUI= GetComponent(); } // Update is called once per frame void Update() { tiger.SetActive(GameState); Ray ray = new Ray(cam.transform.position, cam.transform.forward); playerUI.UpdateText(string.Empty); Debug.DrawRay(ray.origin, ray.direction * distance); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, distance, mask)) { if (hitInfo.collider.GetComponent() != null) { playerUI.UpdateText(hitInfo.collider.GetComponent().message); } if (Input.GetKey(KeyCode.E)) { if (hitInfo.collider.GetComponent() != null) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; hitInfo.collider.GetComponent().BaseInteract(); GameState = false; maincam.SetActive(false); gamecam.SetActive(true); } } } } }