- Home /
How does WaitForSeconds pass values?
I have been trying to add more features to the dialogue system Brackeys made awhile back. One feature I wanted to add was the ability to change the text speed from the Dialogue script. My first thought was to create a float variable in the Dialogue script that I could pass to the DialogueManager script, much like the "name" variable.
 IEnumerator TypeSentence (string sentence)
 {
     dialogueText.text = "";
     foreach (char letter in sentence.ToCharArray())
     {
         
         dialogueText.text += letter;
         yield return new WaitForSeconds(dialogue.textSpeed);
     }
 }
What I noticed was that the WaitForSeconds method was ignored. However, when I inserted the number I wanted to use in the method, it worked perfectly fine.
 IEnumerator TypeSentence (string sentence)
     {
         dialogueText.text = "";
         foreach (char letter in sentence.ToCharArray())
         {
             
             dialogueText.text += letter;
             yield return new WaitForSeconds(0.04f);
         }
     }
I'm not quite sure what causes this, as I am a bit new to couroutines in general. Any answers or explanations would be helpful. Thank you!
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                