- Home /
 
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;
             }
                 
                 
         }
     }
 }
 
              Your answer
 
             Follow this Question
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