Question by
sicklml52_stu · Apr 12, 2019 at 07:58 PM ·
c#coroutinemonobehaviourcoroutinesienumerator
"Can't add script behaviour AICharacterControl. The script needs to derive from MonoBehaviour!" ?
I'm trying to make a typewriter-like text using another question on here but I keep on getting this pop-up saying I'm not able to do so. How do I fix it?
Here's my script:
string[] vicinityText = new string[2]
{
"I see you're unfamiliar with this place... here's some basic enemies. Fight or die trying.",
"Easy enough, right? Now let's test your mathematical knowledge."
};
public Text vicinityTalkBox;
int currentTextDisplayed = 0;
private void Awake()
{
StartCoroutine(AnimateText());
}
IEnumerator AnimateText()
{
for (int x = 0; x < vicinityText[currentTextDisplayed].Length + 1; x++)
{
vicinityTalkBox.text = vicinityText[currentTextDisplayed].Substring(0, x);
yield return new WaitForSeconds(0.3f);
}
}
,I'm trying to add a script that adds coroutines (I'm unexperienced with them) but this pop-up saying that I can't add AICharacterControl repeatedly appears. How do I fix it? Here's my script:
string[] vicinityText = new string[2]
{
"I see you're unfamiliar with this place... here's some basic enemies. Fight or die trying.",
"Easy enough, right? Now let's test your mathematical knowledge."
};
public Text vicinityTalkBox;
int currentTextDisplayed = 0;
private void Awake()
{
StartCoroutine(AnimateText());
}
IEnumerator AnimateText()
{
for (int x = 0; x < vicinityText[currentTextDisplayed].Length + 1; x++)
{
vicinityTalkBox.text = vicinityText[currentTextDisplayed].Substring(0, x);
yield return new WaitForSeconds(0.3f);
}
}
Comment
Your answer
Follow this Question
Related Questions
IEnumerator inner functions 0 Answers
"Can't add script behaviour AICharacterControl. The script needs to derive from MonoBehaviour!" ? 2 Answers
Need help using coroutines 1 Answer
How can i change the value of a variable from an IEnumerator 0 Answers
Using StartCoroutine in a Nested Class 0 Answers