void Update() { //if key 'C' is pressed and everything is set correct, create rope if (Input.GetKeyDown(KeyCode.C)) { //if something isn't set correct don't do anything if (!pointA && !pointsHolder) { Debug.LogWarning("PointA Isn't Assigned"); return; } if (!pointB && !pointsHolder) { Debug.LogWarning("PointB Isn't Assigned"); return; } if (!chainObject) { Debug.LogWarning("Chain Object Isn't Assigned"); return; } if (pointA && pointB && pointA.GetInstanceID() == pointB.GetInstanceID()) { Debug.LogWarning("Same Object Is Assigned For Both PointA and PointB"); return; } //if in pointsHolder is assigned, create rope between its children's positions if (pointsHolder) { pointsHolderArray = new List <Transform>(); //get all children foreach (Transform child in pointsHolder) { pointsHolderArray.Add(child); } //set pointA and pointB and create rope for (int i = 0; i < pointsHolderArray.Count - 1; i++) { pointA = pointsHolderArray[i]; pointB = pointsHolderArray[i + 1]; Create(); } //if connectEndPoints is set to true, create rope between first and last points if (connectEndPoints) { pointA = pointsHolderArray[pointsHolderArray.Count - 1]; pointB = pointsHolderArray[0]; Create(); } } else { Create(); } } //if 'R' key is pressed, remove rope if (Input.GetKeyDown(KeyCode.R)) { rope.Remove(); } }