I am new to Game Dev and I am following a Tutorial. Within this tutorial, we create a quest system, that allows you to accept or decline a quest. This tutorial is based on Unity 5 and I am using 2020.1 so there could be version differences that could be causing the issue.
I have a script called:
Quest001Buttons.cs
public class Quest001Buttons : MonoBehaviour {
public GameObject ThePlayer;
public GameObject NoticeCam;
public GameObject UIQuest;
public GameObject ActiveQuestBox;
public GameObject Objective01;
public GameObject Objective02;
public GameObject Objective03;
public void AcceptQuest() {
Debug.Log("Accept Registered");
ThePlayer.SetActive(true);
NoticeCam.SetActive(false);
UIQuest.SetActive(false);
StartCoroutine(SetQuestUi());
}
IEnumerator SetQuestUi() {
ActiveQuestBox.GetComponent<Text>().text = "My First Weapon";
Objective01.GetComponent<Text>().text = "Reach the Clearing";
Objective02.GetComponent<Text>().text = "Open Chest";
Objective03.GetComponent<Text>().text = "Get Weapon";
QuestManager.ActiveQuestNumber = 1;
yield return new WaitForSeconds(0.5f);
ActiveQuestBox.SetActive(true);
yield return new WaitForSeconds(1);
Objective01.SetActive(true);
yield return new WaitForSeconds(0.5f);
Objective02.SetActive(true);
yield return new WaitForSeconds(0.5f);
Objective03.SetActive(true);
yield return new WaitForSeconds(9);
ActiveQuestBox.SetActive(false);
Objective01.SetActive(false);
Objective02.SetActive(false);
Objective03.SetActive(false);
}
}
I have an Empty GameObject called "QuestButtonManager" which I have assigned the above script to. I also have a UI GamObject called "Accept" and I have attached the QuestButtonManager GameObject to the OnClick() Event within that component. I have selected: "Runtime Only" and the function of "Quest001Buttons.AcceptQuest".
When I run the game and press the Accept Button...the game seems to not function after that and is stuck on that screen, with the button highlighted...not even the Debug.Log text is printed in the console.
Any help is greatly appreciated before I give it up and look for a more updated version to learn on.