public void CreateNode(SplineComponent splineComponent) { GameObject controlPoint = new GameObject("ControlPoint"); // Add the splineComponent component controlPoint.AddComponent <ControlPointComponent>(); SplineCurve splineCurve = splineComponent.GetSplineObject(); Vector3 targetPosition = Vector3.one; Vector3[] controlPoints = splineCurve.controlPoints; int cpLength = controlPoints.Length; int controlPointsPerSegment = splineComponent.GetControlPointsPerSegment(); if (cpLength >= controlPointsPerSegment) { // extrapolate the position from the last two points targetPosition = controlPoints[cpLength - 1] + (controlPoints[cpLength - 1] - controlPoints[cpLength - controlPointsPerSegment]); } controlPoint.transform.position = targetPosition; controlPoint.transform.parent = splineComponent.transform; }