void Update()
    {
        //To detect if clicked outside
        if (rigidBody != null && !isPressed && Input.GetMouseButtonDown(0) && (new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y) - new Vector2(transform.position.x, transform.position.y)).magnitude > 1 && (transform.position - rigidBody.transform.position).magnitude < 0.5f && Time.time - timebwclicks > 0.5f)
        {
            Debug.Log("called");
            timebwclicks = Time.time;
            Debug.Log("asdasd0");
            rigidBody.drag        = 19.71f;
            rigidBody.angularDrag = 4.25f;
            isPressed             = false;
            GetComponent <FollowedBy>().followedby           = null;
            rigidBody.GetComponent <SpringJoint2D>().enabled = false;
            rigidBody.isKinematic = false;
            TrainMove.ExtendTrain(rigidBody.GetComponent <FollowedBy>());
            hasHoveringBlob = false;

            rigidBody.GetComponent <BlobHandler>().held = false;
            rigidBody = null;
        }

        /*    if(rigidBody!=null && TrainMove.PartOfTrain(rigidBody.GetComponentInChildren<FollowedBy>()))
         *  {
         *      rigidBody.drag = 19.71f;
         *      rigidBody.angularDrag = 4.25f;
         *      isPressed = false;
         *      rigidBody.GetComponent<SpringJoint2D>().enabled = false;
         *      rigidBody.isKinematic = false;
         *      TrainMove.ExtendTrain(rigidBody.GetComponent<FollowedBy>());
         *      hasHoveringBlob = false;
         *      GetComponent<FollowedBy>().followedby = null;
         *      rigidBody.GetComponent<BlobHandler>().held = false;
         *      rigidBody = null;
         *  }*/

        if (isPressed)
        {
            Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            if (Vector3.Distance(mousePos, hook.position) > maxDragDistance)
            {
                rigidBody.position = hook.position + (mousePos - hook.position).normalized * maxDragDistance;
            }
            else
            {
                rigidBody.position = mousePos;
            }



            //Debug.Log(rigidBody.GetComponent<SpringJoint2D>().breakForce);
        }
    }
    public void SetRigidBody(Rigidbody2D rb)
    {
        if (rigidBody != null)
        {
            rigidBody.drag        = 19.71f;
            rigidBody.angularDrag = 4.25f;
            isPressed             = false;
            rigidBody.GetComponent <SpringJoint2D>().enabled = false;
            rigidBody.isKinematic = false;
            TrainMove.ExtendTrain(rigidBody.GetComponent <FollowedBy>());
            hasHoveringBlob = false;
            GetComponent <FollowedBy>().followedby      = null;
            rigidBody.GetComponent <BlobHandler>().held = false;
            rigidBody = null;
        }

        GetComponent <FollowedBy>().followedby = rb.GetComponent <FollowedBy>();
        rigidBody = rb;
        /*   rigidBody.transform.SetParent(gameObject.transform,true);*/
        hasHoveringBlob = true;
        rigidBody.GetComponent <BlobHandler>().held = true;
    }
 protected override void OnEnable()
 {
     base.OnEnable();
     TrainMove.ExtendTrain(followObject.GetComponent <FollowedBy>());
 }
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.tag == "BabyBlob")
            {
                int temp = other.GetComponent <BabyBlobHandler>().id;
                switch (temp)
                {
                case 0:
                    stickyBabyCount++;
                    if (stickyBabyCount >= maxBabyCount)
                    {
                        stickyBabyCount = 0;
                        GameObject go = Instantiate(stickyBlobPrefab, other.transform.position + Vector3.forward * -0.2f, Quaternion.identity);
                        go.GetComponent <BlobHandler>().mergePos        = transform.GetChild(0);
                        go.GetComponent <SpringJoint2D>().connectedBody = transform.GetChild(0).GetComponent <Rigidbody2D>();
                        TrainMove.ExtendTrain(go.GetComponent <FollowedBy>());
                        Instantiate(magicPoof, other.transform.position, Quaternion.identity);
                    }
                    else
                    {
                        Instantiate(poof, other.transform.position, Quaternion.identity);
                    }
                    break;

                case 1:
                    fireBabyCount++;
                    if (fireBabyCount >= maxBabyCount)
                    {
                        fireBabyCount = 0;
                        GameObject go = Instantiate(fireBlobPrefab, other.transform.position + Vector3.forward * -0.2f, Quaternion.identity);
                        go.GetComponent <BlobHandler>().mergePos        = transform.GetChild(0);
                        go.GetComponent <SpringJoint2D>().connectedBody = transform.GetChild(0).GetComponent <Rigidbody2D>();
                        TrainMove.ExtendTrain(go.GetComponent <FollowedBy>());
                        Instantiate(magicPoof, other.transform.position, Quaternion.identity);
                    }
                    else
                    {
                        Instantiate(poof, other.transform.position, Quaternion.identity);
                    }
                    break;

                default:
                    waterBabyCount++;
                    if (waterBabyCount >= maxBabyCount)
                    {
                        waterBabyCount = 0;
                        GameObject go = Instantiate(waterBlobPrefab, other.transform.position + Vector3.forward * -0.2f, Quaternion.identity);
                        go.GetComponent <BlobHandler>().mergePos        = transform.GetChild(0);
                        go.GetComponent <SpringJoint2D>().connectedBody = transform.GetChild(0).GetComponent <Rigidbody2D>();
                        TrainMove.ExtendTrain(go.GetComponent <FollowedBy>());
                        Instantiate(magicPoof, other.transform.position, Quaternion.identity);
                    }
                    else
                    {
                        Instantiate(poof, other.transform.position, Quaternion.identity);
                    }
                    break;
                }

                Destroy(other.gameObject);
            }
        }
 public void Add()
 {
     TrainMove.ExtendTrain(this);
 }