private void GenerateRope() { Rigidbody2D previousRb = hook; segments.Add(hook.GetComponent <Transform>()); for (int i = 0; i < links; i++) { GameObject link = Instantiate(linkPrefab, hook.transform); HingeJoint2D joint = link.GetComponent <HingeJoint2D>(); segments.Add(link.transform); // save all the link joint.connectedBody = previousRb; // connect link to previous link (hook will be the first connection) if (i < links - 1) // if not last link { previousRb = link.GetComponent <Rigidbody2D>(); // save this link as previous link } else { candy.ConnectRopEnd(link.GetComponent <Rigidbody2D>()); // pass the link to the candy and to connect (if it the last link) } } cuttedSegments.AddRange(segments); // keep another list of all the links }