//Jimmy Vegas Unity Tutorial //This script is for your NPC using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class NPCChat : MonoBehaviour { public float TheDistance; public GameObject ActionDisplay; public GameObject ActionText; public GameObject ExtraCursor; public GameObject subText; void Update() { TheDistance = PlayerCasting.DistanceFromTarget; } void OnMouseOver() { if (TheDistance <= 3) { ActionDisplay.SetActive(true); ActionText.GetComponent().text = "Talk"; ActionText.SetActive(true); ExtraCursor.SetActive(true); } else { ActionDisplay.SetActive(false); ActionText.SetActive(false); ExtraCursor.SetActive(false); } if (Input.GetButtonDown("Action")) { if (TheDistance <= 3) { subText.GetComponent().text = "Please come back to me when you have a weapon."; this.GetComponent().enabled = false; ActionDisplay.SetActive(false); ActionText.SetActive(false); ExtraCursor.SetActive(false); StartCoroutine(ResetChat()); } } } void OnMouseExit() { ActionDisplay.SetActive(false); ActionText.SetActive(false); ExtraCursor.SetActive(false); } IEnumerator ResetChat() { yield return new WaitForSeconds(2.5f); subText.GetComponent().text = ""; this.GetComponent().enabled = true; } }