- Home /
HELP! Make text appear in scene after 5 seconds?
I am very new to scripting, I have looked all over the internet for an answer to this question. I am making a word adventure type game and basically in this scene all I want is for text to appear after five seconds or so. Please help, I have been using c#, and it would be very helpful if you were to explain how the code for this works, and where I attach the script to! Thanks
Answer by MadDevil · Sep 28, 2015 at 07:34 AM
Use coroutines to get delay in the execution of code.
http://docs.unity3d.com/ScriptReference/MonoBehaviour.StartCoroutine.html
Answer by UsulPro · Sep 28, 2015 at 09:10 AM
Hi, @smlevitt05! You need to create an empty game object and attach script like this :
     public GameObject TextObj;
     float TmStart;
     float TmLen=5f;
 
     // Use this for initialization
     void Start () {
         TmStart=Time.time;
     }
     
     // Update is called once per frame
     void Update () {
         if(Time.time>TmStart + TmLen) 
         {
 
             TextObj.SetActive (true);
         }
     }
After that drag and drop your text to "TextObj" field in the Inspector. Disable your text in inspector before starting.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                