// Draw beziers and handles private void DrawBeziers() { for (int i = 0; i < component.splineCount; i++) { //Draw beziers Color bezierColor = Color.cyan; float bezierWidth = 2f; if (i == activeSpline & tool != 1 && tool != 2) { bezierColor = Color.white; bezierWidth = 2f; } for (int j = 1; j < component.PointCount(i); j++) { Handles.DrawBezier( component.GetPoint(i, j - 1), component.GetPoint(i, j), component.GetHandle(i, j - 1, 1), component.GetHandle(i, j, 0), bezierColor, null, bezierWidth); } //Draw handles for current tool for (int j = 0; j < component.PointCount(i); j++) { switch (tool) { case -1: ShowControlPoint(i, j); break; case 0: ShowControlPoint(i, j); break; case 1: if (component.GetConnectedIndex(i, j) >= 0) { ShowSimplePoint(i, j); } break; case 2: ShowSplinePoint(i); break; } } } }
static void DrawPointProperties(SplineComponent spline) { Vector3 tangent = spline.GetTangent(spline.CurrentPointT); // Vector3 up = spline.GetUp(spline.CurrentPointT); Vector3 normal = spline.GetNormal(spline.CurrentPointT, Vector3.up); Vector3 p = spline.GetPoint(spline.CurrentPointT); Gizmos.color = Color.blue; Gizmos.DrawRay(p, tangent.normalized); Gizmos.color = Color.green; // Gizmos.DrawRay(p, up.normalized); Gizmos.DrawRay(p, normal.normalized); Gizmos.color = Color.red; Gizmos.DrawRay(p, Vector3.Cross(normal, tangent)); Gizmos.color = Color.black; Gizmos.DrawSphere(p, 0.05f); }
void Update() { if (percent >= 1.0f) { direction = -1; } else if (percent <= 0.0f) { direction = 1; } percent += Time.deltaTime * followSpeed * direction; var position = spline.GetPoint(percent); transform.position = position; transform.LookAt(lookAtTarget.transform); }
public void SetControlValue(float v) { body.MovePosition(spline.GetPoint(v)); }