- Home /
Question by
Sayden96 · Jun 24, 2020 at 01:27 PM ·
scripting problemscript.scenechange
The script doesn't work correctly
The script doesn't work correctly when I change the scene and i put the same prefab. I press the selected button but it doesn't work well, it only works well when I move the character constantly.
public class SignScript : MonoBehaviour
{
public Dialogue dialogue;
private gameMaster gm;
void Start()
{
gm = GameObject.FindGameObjectWithTag("GameMaster").GetComponent<gameMaster>();
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.CompareTag("Player"))
{
gm.InputText.text = ("[E] to Read");
if (Input.GetKey("e"))
{
FindObjectOfType<DialogueManager>().StartDialogue(dialogue);
}
}
}
void OnTriggerStay2D(Collider2D col)
{
if (col.CompareTag("Player"))
{
if (Input.GetKey("e"))
{
FindObjectOfType<DialogueManager>().StartDialogue(dialogue);
}
}
}
void OnTriggerExit2D(Collider2D col)
{
if (col.CompareTag("Player"))
{
gm.InputText.text = (" ");
FindObjectOfType<DialogueManager>().EndDialogue();
}
}
}
Comment
Your answer
Follow this Question
Related Questions
(PLEASE HELP) hi guys! i have a problem with my Score text 1 Answer
Change Target from Script in GameObject with another Script 1 Answer
How can i use a script to automatic place invisible walls around the terrain edges ? 1 Answer
How do I play gameobjects in my scene from one script / Script is not working 0 Answers