- Home /
 
 
               Question by 
               josudl · Jan 29, 2017 at 12:19 PM · 
                collidercolliderscollider2dstatic variable  
              
 
              Collider keypad
i'm making a keypad using GameObjects with Collider and this script;
using UnityEngine; using System.Collections;
public class button1 : MonoBehaviour {
 int chevron1;
 int chevron2;
 int chevron3;
 int chevron4;
 int chevron5;
 int chevron6;
 int chevron7;
 bool chevron1set;
 bool chevron2set;
 bool chevron3set;
 bool chevron4set;
 bool chevron5set;
 bool chevron6set;
 bool chevron7set;
 int[] Dial;
 void Start () {
     DHD.chevron1 = chevron1;
     DHD.chevron2 = chevron2;
     DHD.chevron3 = chevron3;
     DHD.chevron4 = chevron4;
     DHD.chevron5 = chevron5;
     DHD.chevron6 = chevron6;
     DHD.chevron7 = chevron7;
     DHD.chevron1set = chevron1set;
     DHD.chevron2set = chevron2set;
     DHD.chevron3set = chevron3set;
     DHD.chevron4set = chevron4set;
     DHD.chevron5set = chevron5set;
     DHD.chevron6set = chevron6set;
     DHD.chevron7set = chevron7set;
     DHD.Dial = Dial;
     Dial = new int[7] { chevron1, chevron2, chevron3, chevron4, chevron5, chevron6, chevron7 };
 }
 
 void OnMouseDown(){
     if (chevron1set == false) {
         chevron1 = 1;
         Debug.Log ("chevron 1 set");
         chevron1set = true;
     }
     else if (chevron1set == true && chevron2set == false) {
         int chevron2 = 1;
         Debug.Log ("chevron 2 set");
         chevron2set = true;
     }
     else if (chevron2set == true && chevron3set == false) {
         int chevron3 = 1;
         Debug.Log ("chevron 3 set");
         chevron3set = true;
     }
     else if (chevron3set == true && chevron4set == false) {
         int chevron4 = 1;
         Debug.Log ("chevron 4 set");
         chevron4set = true;
     }    
     else if (chevron4set == true && chevron5set == false) {
         int chevron5 = 1;
         Debug.Log ("chevron 5 set");
         chevron5set = true;
     }
     else if (chevron5set == true && chevron6set == false) {
         int chevron6 = 1;
         Debug.Log ("chevron 6 set");
         chevron6set = true;
     }
     else if (chevron6set == true && chevron7set == false) {
         int chevron7 = 1;
         Debug.Log ("chevron 7 set");
         chevron7set = true;
     }
 }
 
               }
But it only works when i click on the same Collider all the times. How can I fix it to make it work when I click on different Colliders? Thank you
               Comment
              
 
               
              Your answer