Jul 15, 2024
Player
tag to player GameObject.isTrigger
for dialogue activation.using UnityEngine.UI
GameObject dialogPanel
Text dialogText
String dialogue
(array for sentences)int index
(current position in dialogue)float wordSpeed
(typing speed)bool playerIsClose
OnTriggerEnter2D
and OnTriggerExit2D
methods to set playerIsClose
.ZeroText
function to reset text and deactivate panel.ZeroText
in appropriate places.IEnumerator
Typing
for simulating text typing effect.for each
loop to display characters.yield return new WaitForSeconds(wordSpeed)
.OnClick
event linking to NPC’s NextLine
function.GameObject continueButton
variable in script.NextLine
.