Quantcast
Channel: Questions in topic: "loops"
Viewing all articles
Browse latest Browse all 184

Why does this loop throw an error if int questComplete rises above 1?

$
0
0
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; } } }

Viewing all articles
Browse latest Browse all 184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>