title: Unity joining multiple mesh colliders
body: <p>I'm doing a puzzle game where I have a sphere made up of multiple mesh colliders as slots, and the player is supposed to move puzzle pieces(also mesh colliders) into contact with the sphere where they will stick to the mesh collider 'slot' they collided with. However, my script behaves strangely. It adheres sometimes, and on other times it floats off into the game world by itself. How would I get it to work?</p>
  
  <p>Here's the sphere the puzzle pieces are supposed to stick to, and one of the puzzle pieces itself:
  <img src="https://i91.photobucket.com/albums/k295/ZOMGWTFBBQSauce/stackoverflow2_zps77675103.png" alt="Puzzle"></p>
  
  <p>The sphere is composed of several meshes each with their own mesh collider. The irregularly shaped object on the left is one of the puzzle pieces. When the player moves it towards the sphere it should stick to the first mesh collider on the sphere it comes into contact with.</p>
  
  <p>And here's my script:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class StickyObject : MonoBehaviour {
  
      DragToMove1 otherScript;
      GameObject mainObj, jigsphere;
      bool stuck;
      public LayerMask layerMask;
      // Use this for initialization
      void Start () 
      {
          otherScript = this.GetComponent&lt;DragToMove1&gt;();
          mainObj = GameObject.Find("GameObject");
          stuck = false;
      }
  
      // Update is called once per frame
      void Update () 
      {
          if (stuck) 
          {
          }
  
      }
  
      void OnCollisionEnter(Collision c) 
      {
          if (!stuck) 
          {
  
              //By contact point
              ContactPoint touched = c.contacts[0];
              Debug.Log ("Collision with " + this.name);
  
              touched.otherCollider.gameObject.transform.parent = this.transform;
  
              Debug.Log ("Parented to " + touched.otherCollider);
  
              stuck = true;
  
              if (otherScript != null) 
              {
                  otherScript.Stuck();
                  otherScript.selected = false;
              }
  
              mainObj.SendMessage ("Wake");
          }
      }
  
      bool getStuck()
      {
          return stuck;
      }
  }
  </code></pre>