void Update() { if (spline == null) { enabled = false; return; } if (followBehaviour == SplineFollowBehaviour.oneGo) { OneGoEvaluateInterpolateAmount(); } else if (followBehaviour == SplineFollowBehaviour.loop) { LoopEvaluateInterpolateAmount(); } else if (followBehaviour == SplineFollowBehaviour.backAndForth) { BackAndForthEvaluateInterpolateAmount(); } transform.position = spline.GetPosition( interpolateAmount.Remap(0f, followDuration, 0f, 1f) ); }
private void UpdateMesh() { if (mesh != null) { mesh.Clear(); Destroy(mesh); mesh = null; } if (spline.Anchors.Count < 2) { return; } var meshBuilder = new LineMeshBuilder() .Width(meshWidth); var meshStep = 1 / meshSubdivisions; for (var size = 0f; size <= 1f; size += meshStep) { meshBuilder.AddPoint(spline.GetPosition(size)); } mesh = meshBuilder.Build(); meshFilter.mesh = mesh; }