Hi! I have this code bellow for when my player gets on a NPC collider. This NPC turns into child of a dialogue system gameobject, and then in the middle of the code this IEnumerator gets executed to type the sentences characters one by one, but when i leave the trigger and the NPC is not a child anymore, the dialogue panel gets disabled and it gives me a Nullreference. Is it because of the WaitForSeconds?
The code works perflectly, but i would like to know if there’s some way of not showing this error. Just for console porpuses.
IEnumerator TypeSentence(string sentence) {
dialogueText.text = "";
foreach (char letter in sentence.ToCharArray()) {
dialogueText.text += letter;
yield return new WaitForSeconds(.03f);
}
}