I’m working on a prototype for a project I’m planning out right now and I’m working on a basic dialogue system. I’ve decided to have a manager for the text that the NPC you are talking to says. I have a function called “ShowSubtitles” where when called, it sets the subtitles box to be active and changes the text in the subtitles to whatever parameter you put for the text. Right now in the script for the NPC’s dialogue I’m trying to have him say something, wait 5 seconds, then say the next thing. I’ve set the waiting up with a coroutine but I haven’t really used them before. Once I try to call the wait coroutine with the parameter of how long I want it to wait, I get the error “Failed to call function “wait” of class “Dialogue”. Calling function “wait” with no parameters but the function requires 1.”
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LucasSimmsDialogue : MonoBehaviour {
private SubtitlesManager sMan;
void Start() {
sMan = FindObjectOfType<SubtitlesManager>();
StartCoroutine( "Wait" );
}
void OnCollisionStay2D(Collision2D other)
{
if( other.gameObject.tag == "Player")
{
if ( Input.GetKeyUp(KeyCode.E) )
{
InitiateConversation();
}
}
}
IEnumerator Wait(int time)
{
Debug.Log( "Waiting.." );
yield return new WaitForSeconds(time);
}
void InitiateConversation()
{
sMan.ShowSubtitles( "Name\'s Lucas Simms, town sheriff. And Mayor too, when the need arises." );
StartCoroutine(Wait(5));
sMan.ShowSubtitles( "I don\'t why, but I like you, boy! Something tells me you're all right. So welcome to Megaton! Just holler if you need something." );
}
}
Gizmos have no functionality to handle input events, they're purely for display, so they won't do. Editor Windows need to be opened separately rather than being a part of the main scene editor, so that falls short too.
– Ashkin