- Home /
How to make "check collider" for 3 another colliders?

Here's the my 4 colliders. I want to make checkLock (high narrow collider) like a check collider for 3 another colliders (first1, second2, third3). It's like a puzzle, where all 3 numbers have to be at the top. I've tryed to make this through the degrees and rotation, but I've got strage results sometimes (-1.4 ). I don't know why it is so, but if someone explain my why, I'll be very happy. So, here's my code:
 public void MoveCircle(string objname)
         {
                
                 if (Input.GetKeyDown(KeyCode.E)) {
                         GameObject.Find (objname).transform.Rotate (0, 0, -45);
                 }
                
                 if (Input.GetKeyDown(KeyCode.Q)) {
                         GameObject.Find (objname).transform.Rotate (0, 0, 45);
                 }
 }
         void OnTriggerStay2D (Collider2D other) {
                 if (other.gameObject.tag == "1") {
                         MoveCircle("first1");
                 }
 
                 if (other.gameObject.tag == "2") {
                         MoveCircle("second2");
                 }
                
                 if (other.gameObject.tag == "3") {
                         MoveCircle("third3");
                 }
 }
How can I make this? I want to make OnTriggerStay2D for checkLock and smth like: When(first1&&second2&&third3 on checkLock) some variable equals 1. When not - 0. Hope for you.
Answer by JigneshKoradiya · Mar 18, 2015 at 11:56 PM
you can check with
if(gameobject1.collider.bounds.intersect(gameobject2.collider.bounds)) { Debug.Log("colliding"); }
Answer by 7KiLL · Mar 19, 2015 at 10:42 PM
 if (GameObject.Find("checkLock").collider2D.bounds.Intersects(GameObject.Find("first1").collider2D.bounds)&&GameObject.Find("checkLock").collider2D.bounds.Intersects(GameObject.Find("second2").collider2D.bounds)&&GameObject.Find("checkLock").collider2D.bounds.Intersects(GameObject.Find("third3").collider2D.bounds))
             {
             locc = 1;
         }
 
 else { 
 locc = 0;
 }
So there it is. Just put it into fixed and have fun.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                