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
2 Answers
2Hi, @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.
Use coroutines to get delay in the execution of code.
Or ... [http://docs.unity3d.com/ScriptReference/MonoBehaviour.Invoke.html][1] [1]: http://docs.unity3d.com/ScriptReference/MonoBehaviour.Invoke.html
– saschandroid