- Home /
not taking input
im trying to make a dialogue system for my game and i followed an online tutorial and did some changes in it but it only shows talk on screen but its not taking input instead shows 'input not found' in the log. the original coding was working fine for me but the code in not working anymore after my changes. can anyone tell me what am i doing wrong? im stuck at this
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class DialogueScript : MonoBehaviour {
public GameObject ActionCanvas;
public GameObject ActionChar;//shows [e] on screen
public GameObject ActionText;//shows talk on screen
public GameObject DialogueCanvas;
public GameObject TextBox;//panel
public GameObject DialogueName;//name textbox
public GameObject DialogueText;//text textbox
void OnTriggerEnter(Collider col)
{
ActionText.GetComponent<Text> ().text = "Talk";
ActionCanvas.SetActive (true);
if (Input.GetButtonDown ("Action")) {
ActionCanvas.SetActive (false);
StartCoroutine (NPC001Active ());
}
else
{
Debug.Log("input not found", gameObject);
}
}
IEnumerator NPC001Active () {
DialogueCanvas.SetActive (true);
TextBox.SetActive (true);
DialogueName.GetComponent<Text> ().text = "Warrior";
DialogueText.GetComponent<Text>().text = "Hello friend, I may have a quest for you if you wish to accept it. Please come back later on this afternoon.";
yield return new WaitForSeconds(5.5f);
DialogueCanvas.SetActive (false);
ActionCanvas.SetActive (true);
}
}
https://jvunity.weebly.com/uploads/4/7/6/0/47606749/rpg_016_scripts.txt this is the original code and uses raycasting but im working on trigger
Answer by Sonky108 · Sep 13, 2018 at 08:10 AM
It has nearly no chances (if any) to work. The game need to meet two requirements to show dialogue. First OnTriggerEnter
need to occure which is called once and at the same time Action button need to be pressed not held down. As you can see the situation is nearly impossible.
oh now i understand, thanks. Can you suggest me any other way similar to it?
I can, but I need to know how you want it to behave. For now it seems that you've tried you make something like: 1. Go near the character; 2. Press the button to talk.
Right?
yes, i want the the player to go near a character, (there will be option if the player wants to interact or not but ive kept it for afterwards), then press button and dialogues appear, then the player accepts or declines a task at the end of the conversation. im basically trying to make a decision driven game but as im kinda new to unity so im encountering problems related to coding in it.
Your answer
Follow this Question
Related Questions
Dialogue Code 0 Answers
Operator '*' cannot be used with a left hand side ....... 1 Answer
cant install unity 1 Answer
Character keeps moving in one direction on its own 4 Answers