Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Rin_Vael · Jun 02, 2017 at 10:49 PM · uitextnpcdialogue

How to reset NPC dialogue?

I am working on a project that allows the player to move around and interact with 3 NPCs. So far the player has the ability to move around and approach the NPCs (approaching them will trigger text to appear on the screen that says "Press 'E' to Talk" ). The problem is when I approach an NPC (which triggers the text "Press 'E' to Talk") and when 'E' is pressed I can get a response from the NPCs but it is only one response currently and I do not know how to reset the text so I can interact with them many times repeatedly. For example, when I approach them and press 'E' I get a text response but when I approach other NPCs or even the same NPC the text that was displayed previously shows up again instead of "Press 'E' to Talk". Is there a way to reset the text so that I can interact with 3 NPCs multiple times and have different dialogue for each? I have included some examples of the scripts that I am using to help.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class Player : MonoBehaviour 
 {
 
     private GameObject triggeringNPC;
     private bool triggering;
 
     public GameObject NPCText;
 
 
     void Update()
     {
         if (triggering) 
         {
             NPCText.SetActive (true);
         } 
         else 
         {
             NPCText.SetActive (false);
         }
     }
 
 
     void OnTriggerEnter (Collider other)
     {
         if (other.tag == "NPC") 
         {
             triggering = true;
             triggeringNPC = other.gameObject;
         }
     }
 
 
     void OnTriggerExit (Collider other)
     {
         if (other.tag == "NPC") 
         {
             triggering = false;
             triggeringNPC = null;
         }
     }
 
 
 }
 

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class NPCDialogue : MonoBehaviour 
 {
     [SerializeField]
     private Text Dialogue = null; 
 
     string NPC1 = "I am NPC1";
     string NPC2 = "I am NPC2";
     string NPC3 = "I am NPC3";
 
 
     void Update () 
     {
         if(Input.GetKeyDown(KeyCode.E))
         {
             Dialogue.text = NPC1;
         }
     }
 
 }
 
 
 



Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

145 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Best Practice For Storing RPG Dialogue? 1 Answer

Text Mesh pro won't show certain characters 1 Answer

Text won't properly update in Unity Bolt 1 Answer

Unity 5 - Does anyone know how to scale the text in the UI? 1 Answer

Resizing font by scale according to screen size, (More complicated than you might think) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges