Hi, I’m beginner on Unity and I didn’t find an answer to my question on the web, so I ask it here (and sorry if my English is not perfect, I’m French). So, I created a quest system that use many scripts with the same variables names, but with different names which allows me to identify them (Example : quest_1_1_201, the first number is the ID of the quest, the second is the number of steps to finish it… but the script variables names are the same than quest_2_1_101 for example), and I want to get their variables without knowing their names, just with a string that display the current quest. For example, if I want to know if the currentStep of the quest is 3, I tried this :
public string currentQuestID;
void Update () {
currentQuestID = GetComponent<RPGQuestManager>().currentQuestID;
//in the quest manager script are listed all the quest that are accepted by the player, but only one can be selected
if (GetComponent(currentQuestID)) {
if (GetComponent(currentQuestID).currentStep == 3) {
Debug.Log ("It works !");
}
}
}
But it doesn’t work, I don’t know how to access this variable, I spent hours on this forum and I tried lot of methods but none has worked, or it was just to hard for me.
Anyone could help me please ?