Now I'm definitely still learning about how loops work so it's a bit of voodoo I have to throw into each code, but I can't for the life of me tease out why this script wouldn't work on two or even infinite quests. Little help?
using UnityEngine;
using System.Collections;
public class completedQuests : MonoBehaviour {
private questLogic mainScript;
public baseQuest[] finishedQuests;
public bool hasRun;
private int incrementChecker;
public int questsComplete;
public int orderCompleted = 0;
// Use this for initialization
void Start () {
mainScript = GetComponent();
incrementChecker = questsComplete;
}
// Update is called once per frame
void Update () {
if(questsComplete != incrementChecker){
finishedQuests = new baseQuest[questsComplete];
for(int i = 0; i < mainScript.allQuests.Length; i++){
if(mainScript.allQuests[i].currentStatus == mainScript.allQuests[i].questLength){
error line==> finishedQuests[orderCompleted] = mainScript.allQuests[i];
orderCompleted++;
}
}
incrementChecker = questsComplete;
}
}
}
↧