Goodmorning everyone,
I state that I am absolutely new to programming languages (who knows how many discussions start this way), so I am truly ignorant on the subject.
I am following tutorials to “create a video game” for personal hobby, but for two days I have been going crazy behind a script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityStandardAssets.Characters.FirstPerson;
public class Inizio_001 : MonoBehaviour
{
public GameObject playerObject;
public GameObject FadeScreenIn;
public GameObject SfondoNero;
public GameObject TextBox;
// Start is called before the first frame update
void Start()
{
playerObject.GetComponent<FirstPersonController>().enabled = false;
StartCoroutine (ScenePlayer());
}
IEnumerator ScenePlayer ()
{
SfondoNero.SetActive (true);
yield return new WaitForSeconds (2f);
TextBox.GetComponent<Text> ().text = "...";
yield return new WaitForSeconds (2);
TextBox.GetComponent<Text> ().text = "La mia...";
yield return new WaitForSeconds (2);
TextBox.GetComponent<Text> ().text = "La mia testa...";
yield return new WaitForSeconds (2);
TextBox.GetComponent<Text> ().text = "Fa un male cane...";
yield return new WaitForSeconds (2);
TextBox.GetComponent<Text> ().text = "...";
yield return new WaitForSeconds (2);
TextBox.GetComponent<Text> ().text = "Dove mi trovo?";
yield return new WaitForSeconds (2);
SfondoNero.SetActive (false);
FadeScreenIn.SetActive (true);
yield return new WaitForSeconds (2);
TextBox.GetComponent<Text> ().text = "...";
yield return new WaitForSeconds (2);
TextBox.GetComponent<Text> ().text = "Cos'è questo posto?!";
yield return new WaitForSeconds (2);
TextBox.GetComponent<Text> ().text = "";
playerObject.GetComponent<FirstPersonController>().enabled = true;
}
}
Practically: the game start on a black background and on this background, texts appear. I wish these texts could proceed by pressing a button on the keyboard and automatically with the “WaitForSeconds” command as I did (to fall back on the problem).
How can I solve this?
Thanks so much!