Cool idea the game jam ended months ago and i am working on this game full time so i am open to ideas for the dialogue!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CharacterInnerThoughts : MonoBehaviour
{
public Text textDisplay;
public string[] sentences;
private int index;
public float speed;
public float destroyTime;
public GameObject theCanvas;
IEnumerator Type()
{
foreach(char letter in sentences[index].ToCharArray())
{
textDisplay.text += letter;
yield return new WaitForSeconds(speed);
RemoveText();
}
}
void OnTriggerEnter2D(Collider2D col)
{
if(col.gameObject.tag == "Player")
{
StartCoroutine(Type());
}
}
void RemoveText()
{
Destroy(textDisplay, destroyTime);
Destroy(theCanvas, destroyTime);
}
}
Here's the code: https://drive.google.com/file/d/1w7wA0ZgzTczIuiYd-LKEi-o3tQZGH81e/view?usp=shari...
It's a UnityPackage
Explanations are in the code as comments, if you need help with any other code, just ask. There are two scripts, and both of them are needed, if you need help setting it up, I can record my screen and send you the video. :)