Question by
jaydenhall125 · May 10, 2020 at 12:51 AM ·
c#2d gametypedialogue
TypeWriter effect on existing dialogue system?
I watched a video series on youtube on how to make a dialogue system for my game, this is the link " https://www.youtube.com/watch?v=BrCxFpZFRS0&t=787s ". the video has 3 parts and i watched all 3 but it does not explain how to make a typewriter effect (I thought it did). can any one help me and explain how to add that effect?
public class DialogueManager : MonoBehaviour
{
public GameObject dBox;
public Text dText;
public bool dialogActive;
[TextArea(3, 10)]
public string[] dialogLines;
public int currentLine;
private PlayerMovement thePlayer;
// Start is called before the first frame update
void Start()
{
thePlayer = FindObjectOfType<PlayerMovement>();
}
// Update is called once per frame
void Update()
{
if (dialogActive && Input.GetKeyDown(KeyCode.Q))
{
//dBox.SetActive(false);
//dialogActive = false;
currentLine++;
}
if(currentLine >= dialogLines.Length)
{
dBox.SetActive(false);
dialogActive = false;
currentLine = 0;
thePlayer.canMove = true;
GameObject.Find("Player").GetComponent<PlayerMovement>().enabled = true;
}
dText.text = dialogLines[currentLine];
}
public void ShowBox(string dialogue)
{
dialogActive = true;
dBox.SetActive(true);
dText.text = dialogue;
}
public void ShowDialogue()
{
dialogActive = true;
dBox.SetActive(true);
thePlayer.canMove = false;
GameObject.Find("Player").GetComponent<PlayerMovement>().enabled = false;
}
}
public class dialogHolder : MonoBehaviour
{
public string dialogue;
private DialogueManager dMAn;
[TextArea(3, 10)]
public string[] dialogueLines;
// Start is called before the first frame update
void Start()
{
dMAn = FindObjectOfType<DialogueManager>();
}
// Update is called once per frame
void Update()
{
}
void OnTriggerStay2D(Collider2D other)
{
if(other.gameObject.tag == "Player")
{
if(Input.GetKeyUp(KeyCode.E))
{
//dMAn.ShowBox(dialogue);
if (!dMAn.dialogActive)
{
SoundManagerScript.PlaySound("talk");
dMAn.dialogLines = dialogueLines;
dMAn.currentLine = 0;
dMAn.ShowDialogue();
}
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
how create EndLess game Like zombie Tsunami 1 Answer
problim with dontdestroyonload and counts death as 2 0 Answers
Is there any way to trigger a popUp UI when a player steps in a specific set of tiles? 0 Answers
Help in conversion of variable types c# 1 Answer
How to move a game object to a position after selecting it 0 Answers