I am trying to display instructions within the Unity game. The idea is to have the instructions appear over time. For example, "instruction 1" then wait 5 seconds and show "instruction 2" instead of instruction 1 (on the same spot, in this case, I am changing the "message" variable in the code to change the instructions). This code does change the instructions but the problem is that it does it in a haphazard fashion. It appears that "instruction 1" is replaced with "instruction 2" and then it reverts back to "instruction 1" within a second and then back to "instruction 2" so instead of just 1-appearing->1-disappearing->2-appearing->etc in a smooth fashion, it does this weird flashing thing before proceeding to the next instruction. How could I fix this?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Growing : MonoBehaviour {
public Text instructions;
public string message;
void Start () {
instructions.text = message;
}
void Update () {
Instructions();
//other code to begin moving a game object
}
IEnumerator Instructions() {
//run instructions
message = "GET READY FOR YOUR FOCUSED BREATHING EXERCISE";
yield return new WaitForSecondsRealtime(5);
message = "MAKE SURE YOUR BODY IS COMFORTABLE";
yield return new WaitForSecondsRealtime(5);
}