Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Interact : MonoBehaviour
- {
- [SerializeField] private Camera playerCam;
- void Update()
- {
- if(Input.GetKeyDown(KeyCode.E))
- {
- Ray ray = playerCam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, 2f))
- {
- if(hit.transform.GetComponent<TerminalBehaviours>() != null)
- {
- hit.transform.GetComponent<TerminalBehaviours>().InitInteraction(gameObject, playerCam, "E");
- }
- if(hit.transform.GetComponent<SecDoor>() != null)
- {
- hit.transform.GetComponent<SecDoor>().StartScan();
- }
- }
- }
- if(Input.GetKeyDown(KeyCode.Escape))
- {
- Ray ray = playerCam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, 1f))
- {
- if(hit.transform.GetComponent<TerminalBehaviours>() != null)
- {
- hit.transform.GetComponent<TerminalBehaviours>().InitInteraction(gameObject, playerCam, "Esc");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement