Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by joe7987 · Jan 15, 2014 at 05:25 PM · dialoguechat

Two distinct triggers/scripts shouldn't be interacting, but are.

Long story short, I have two dialogue systems (not dialogue box. dialogue as in, NPC talks to player). I have it rigged so that it starts when the player enters a trigger. Then a counter starts. 0 delivers the first line of text. The player hit space, it increments, and 1 delivers the next line, etc.

The first trigger / dialogue session worked fine. Then I added another one, with a different name, and a different script, and different count variables, and everything just sort of broke. -For the first one, the count should get to 11 before ending the dialogue session. It worked until I added the second one. Now it ends at 7, which is coincidentally (probably not) the same time that the second one should end. The character controller/etc. are re-enabled and you can then walk into it again and continue where you left off, until it gets to the actual end. -After ending the first one, its collider is disabled (as intended) but the second one's collider is also disabled, meaning the second one can never trigger.

It really looks like the first trigger/script is not only incrementing its count variable, but also the second one's count variable. I've been through the code time and time again, but I can't seem to find the problem, or any evidence of a shared count variable. The code is below. The first one is listed first. The second is listed second. Any help would be GREATLY appreciated.

StartTextMotor Script

 var startMotorChatProg = 0;
 
 function OnTriggerEnter (other: Collider) {
     
     if (other.tag=="Player"){
     
         var startMotorChatProg = 0;
         var st:GameObject=GameObject.Find("SickText1");
         var textMesh:TextMesh = st.GetComponent(TextMesh);
         var tb:GameObject=GameObject.Find("TextBackground");
         var m:GameObject=GameObject.Find("MainChar");
         var startMotorStartDialogue:boolean=true;
     
     
         PlayerHealth.countDownState = 0;
         m.GetComponent(CharController2D).enabled = false;
         m.GetComponent(AnimateTexture).enabled = false;
         m.GetComponent(PlayerAudio).enabled = false;
     
         tb.renderer.enabled = true;
         st.renderer.enabled = true;
     
     
         textMesh.text = "Hey! You with the crazy hair - Come here!";
     }
     
 }
 
 
 function Update () {
     var st:GameObject=GameObject.Find("SickText1");
     var textMesh:TextMesh = st.GetComponent(TextMesh);
     var tb:GameObject=GameObject.Find("TextBackground");
     var tw = FindObjectOfType(typeof(TextWrap));
     var m:GameObject=GameObject.Find("MainChar");
     var pa:GameObject=GameObject.Find("Player Audio");
     var startMotorStartDialogue:boolean=true;
     
     if (Input.GetButtonDown("Space")){
         if (startMotorStartDialogue==true){
             if(startMotorChatProg ==0){
                 startMotorChatProg =1;
                 textMesh.text = "You look like a local, but I’m not up to taking any chances.";
             }else if(startMotorChatProg==1){
                 startMotorChatProg =2;
                 textMesh.text = "This is the town of “Motor Cortex.” Weird name, right?";
             }else if(startMotorChatProg==2){
                 startMotorChatProg =3;
                 textMesh.text = "Don’t look at me like that. I didn’t name it. Enough with your distractions - We’re in trouble!";
                 tw.updateText();
             }else if(startMotorChatProg==3){
                 startMotorChatProg =4;
                 textMesh.text = "The evil King Myelin is wreaking havoc on our town. He’s afflicting the citizens with a weird sickness. So are you, or aren’t you a local?";
                 tw.updateText();
             }else if(startMotorChatProg==4){
                 startMotorChatProg =5;
                 textMesh.text = "You are? Great! So then you have the Motor Cortex ability?";
                 tw.updateText();
             }else if(startMotorChatProg==5){
                 startMotorChatProg =6;
                 textMesh.text = "Good, when you see a citizen who can't control their body movement, I’ve heard that you can use it to help by clicking the “Motor Cortex” button";
                 tw.updateText();    
             }else if (startMotorChatProg==6){
                 startMotorChatProg =7;
                 textMesh.text = "What is “click” and what’s a “button?” Beats me.";
             }else if (startMotorChatProg==7){
                 startMotorChatProg =8;
                 textMesh.text = "Someone else told me you can press the “Ctrl” button to shoot brainwaves from your head, and that you can run left and right with the “a” and “d” keys.";
                 tw.updateText();
             }else if(startMotorChatProg==8){
                 startMotorChatProg = 9;
                 textMesh.text = "Oh yea, you can also jump using the “spacebar.”";
             }else if (startMotorChatProg==9){
                 startMotorChatProg = 10;
                 textMesh.text = "I don’t really know what all that means, but it’s your problem now, buddy.";
                 tw.updateText();
             }else if(startMotorChatProg==10){
                 startMotorChatProg = 11;
                 textMesh.text = "Quite frankly, I’m tired of you bugging me. Now make yourself handy and save our city.";
                 tw.updateText();
             }else if(startMotorChatProg==11){
                 PlayerHealth.countDownState = 1;
                 collider.enabled = false;
                 m.GetComponent(CharController2D).enabled = true;
                 m.GetComponent(AnimateTexture).enabled = true;
     
                 tb.renderer.enabled = false;
                 st.renderer.enabled = false;
                 startMotorChatProg = 12;
                 startMotorStartDialogue = false;
                 m.GetComponent(PlayerAudio).enabled = true;
             }
                 
                 
         }
     }
 }






EndTextMotor Script

 var chatProgression2 = 0;
 
 function OnTriggerEnter (other: Collider) {
     
     if (other.tag=="Player"){
         var chatProgression2 = 0;
         var st:GameObject=GameObject.Find("SickText1");
         var textMesh:TextMesh = st.GetComponent(TextMesh);
         var tb:GameObject=GameObject.Find("TextBackground");
         var m:GameObject=GameObject.Find("MainChar");
         var startMotorEndDialogue:boolean=true;
     
     
         PlayerHealth.countDownState = 0;
         m.GetComponent(CharController2D).enabled = false;
         m.GetComponent(AnimateTexture).enabled = false;
         m.GetComponent(PlayerAudio).enabled = false;
     
         tb.renderer.enabled = true;
         st.renderer.enabled = true;
     
     
         textMesh.text = "Thank you! But our princess is in another cas… No, that’s not right.";
     }
     
 }
 
 
 function Update () {
     var st:GameObject=GameObject.Find("SickText1");
     var textMesh:TextMesh = st.GetComponent(TextMesh);
     var tb:GameObject=GameObject.Find("TextBackground");
     var tw = FindObjectOfType(typeof(TextWrap));
     var m:GameObject=GameObject.Find("MainChar");
     var pa:GameObject=GameObject.Find("Player Audio");
     var startMotorEndDialogue:boolean=true;
     
     if (Input.GetButtonDown("Space")){
         if (startMotorEndDialogue==true){
             if(chatProgression2 ==0){
                 chatProgression2 =1;
                 textMesh.text = "You’ve saved the citizens of Motor Cortex! Now they can get back to having full control of their bodies!";
             }else if(chatProgression2==1){
                 chatProgression2 =2;
                 textMesh.text = "Unfortunately, I’ve heard that several of them hobbled away in terror when Myelin came.";
             }else if(chatProgression2==2){
                 chatProgression2 =3;
                 textMesh.text = "I think there are going to be more Motor Cortex citizens all around the planet of Medulla.";
                 tw.updateText();
             }else if(chatProgression2==3){
                 chatProgression2 =4;
                 textMesh.text = "You’ll have to seek them out and cure them, so don’t forget about your Motor Cortex ability!";
                 tw.updateText();
             }else if(chatProgression2==4){
                 chatProgression2 =5;
                 textMesh.text = "For now, I bet Occipital could use some help. That’s where Myelin was headed after he left us.";
                 tw.updateText();
             }else if(chatProgression2==5){
                 chatProgression2 =6;
                 textMesh.text = "Why are you still standing here? Don't you know how this works?";
                 tw.updateText();    
             }else if (chatProgression2==6){
                 chatProgression2 =7;
                 textMesh.text = "You're the 'hero'. You saved us, so now you HAVE to save the rest of the world. Get moving! Oh yea, and thank you, or something. Now get outta my face!";
             }else if(chatProgression2==7){
                 PlayerHealth.countDownState = 1;
                 collider.enabled = false;
                 m.GetComponent(CharController2D).enabled = true;
                 m.GetComponent(AnimateTexture).enabled = true;
     
                 tb.renderer.enabled = false;
                 st.renderer.enabled = false;
                 chatProgression2 = 8;
                 startMotorEndDialogueEnd = false;
                 m.GetComponent(PlayerAudio).enabled = true;
             }
                 
                 
         }
     }
 }
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

18 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

Related Questions

How can i create a conversion like whatsapp in unity3d 0 Answers

Unity and Facebook chat? 1 Answer

Help with chatting to NPC, click F for gui box etc 1 Answer

Getting error when making a chat system 0 Answers

Voice Chat Script help? 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