I'm trying to learn how to use Coroutines with Unity and I'm having trouble and keep getting a nullreferenceexception.
I've read a number of pages on this same issue from stack exchange and unity but I can't seem to tie the answers to my own code.
public void takeTopTask(Queue queue){
if (availability == false) {
Debug.LogError (name+" is not available to take a task");
} else {
task takenTask = (task)queue.Dequeue ();
string taskName = takenTask.getName ();
Debug.Log (taskName + " was taken by " + name);
StartCoroutine(doTask(takenTask));
}
}
IEnumerator doTask(task task){
//do the task or something
yield return new WaitForSeconds (task.getLength ());
}
Any help would be HUGELY appreciated!