//Jimmy Vegas Unity Tutorial //These scripts are for your npc and spider //NPC script using UnityEngine.UI; public class NPC001 : MonoBehaviour { public float TheDistance; public GameObject ActionDisplay; public GameObject ActionText; public GameObject ThePlayer; public GameObject TextBox; public GameObject NPCName; public GameObject NPCText; void Update () { TheDistance = PlayerCasting.DistanceFromTarget; } void OnMouseOver () { if (TheDistance <= 3) { AttackBlocker.BlockSword = 1; ActionText.GetComponent ().text = "Talk"; ActionDisplay.SetActive (true); ActionText.SetActive (true); } if (Input.GetButtonDown ("Action")) { if (TheDistance <= 3) { AttackBlocker.BlockSword = 2; Screen.lockCursor = false; Cursor.visible = true; ActionDisplay.SetActive (false); ActionText.SetActive (false); //ThePlayer.SetActive (false); StartCoroutine (NPC001Active ()); } } } void OnMouseExit() { AttackBlocker.BlockSword = 0; ActionDisplay.SetActive (false); ActionText.SetActive (false); } IEnumerator NPC001Active () { TextBox.SetActive (true); NPCName.GetComponent ().text = "Warrior"; NPCName.SetActive (true); NPCText.GetComponent().text = "Hello friend, I may have a quest for you if you wish to accept it. Please come back later on this afternoon."; NPCText.SetActive(true); yield return new WaitForSeconds(5.5f); NPCName.SetActive(false); NPCText.SetActive(false); TextBox.SetActive(false); ActionDisplay.SetActive (true); ActionText.SetActive (true); } } //spider looking public class SpiderAI : MonoBehaviour { public GameObject ThePlayer; void Update () { transform.LookAt (ThePlayer.transform); } }