public void SetTorus(int Segments, int CurveIncrement, int TubeIncrement, float MajorRadius, float MinorRadius, float Rotation) { this.Segments = Segments + 1; CurveSegments = CurveIncrement; tubeIncrement = TubeIncrement; this.MajorRadius = MajorRadius; minorRadius = MinorRadius; this.Rotation = Rotation; GenerateMesh(); //Set this tubesegment as a child to it's pivot, so it can be turned from a pivot not centered on the object pivot = transform.parent; //Allign this tube segment so the pivot is in the center of the opening of the tube transform.localPosition -= new Vector3(MajorRadius, 0, 0); connector = new GameObject("Connector").transform; connector.SetParent(transform); float curveAngle = 2f * Mathf.PI / (float)CurveSegments; //Set the connector object at the center of the end pipe connector.localPosition = Torus.PointOnCurve(curveAngle * Segments); //Turn the connector to face out the pipe connector.localRotation = Quaternion.Euler(0, 0, (Segments / (float)CurveSegments) * 360f); RadiansCovered = Segments * curveAngle; }