Question by
BroDevIsWow · Nov 01, 2021 at 02:06 PM ·
development
How to make text scroll like undertale
So basically I'm trying to make it to where every character appears in a text individually like the text in undertale. Here is my code, what should I change to make this work:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class interobject : MonoBehaviour
{
public GameObject dialogBox;
public Text dialogText;
public string dialog;
public bool playerInRange;
void Update()
{
if(Input.GetKeyDown(KeyCode.E) && playerInRange)
{
if(dialogBox.activeInHierarchy)
{
dialogBox.SetActive(false);
}
else
{
dialogBox.SetActive(true);
dialogText.text = dialog;
}
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if(other.CompareTag("Player"))
{
playerInRange = true;
}
}
private void OnTriggerExit2D(Collider2D other)
{
if(other.CompareTag("Player"))
{
playerInRange = false;
dialogBox.SetActive(false);
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613044819im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to start developing for iOS? 0 Answers
Sound Not Working on Android 0 Answers
What should I do? 2 Answers
How should I approach (or go about) developing games? 1 Answer
Help with Enemy IA walk-Attack-Retreat Jumping-wait-repeat 0 Answers