public void MoveSpline(FluffyUnderware.Curvy.CurvySpline spline_ = null) { if (spline_ != null) { this.spline = spline_; } if ((this.speed == 0) || (this.controller == null) || (this.spline == null)) { return; } //Debug.LogError("MoveSpline " + this.name + " spline=" + this.spline.name + " speed=" + this.speed); Vector3 currentPos = this.transform.position; Vector3 nearestPoint; float nearestT = this.spline.GetNearestPointTF(currentPos, out nearestPoint); if (this.controller.Spline != null) { float duration = Vector3.Distance(currentPos, nearestPoint) / this.speed; this.controller.SwitchTo(this.spline, nearestT, duration); } else { this.controller.Spline = this.spline; this.controller.InitialPosition = Mathf.Max(nearestT, 0.001f) + 0.01f; } //Debug.LogError(" currentPos=" + currentPos.ToString() + " nearestPoint=" + nearestPoint.ToString() + " nearestT=" + nearestT); this.controller.Play(); }
public void ChangeSpline(Vector3 direction, float maxAngle) { if (this.splineGroup == null) { return; } float currentT = this.controller.Position; FluffyUnderware.Curvy.CurvySpline newSpline = this.splineGroup.GetChangeSpline(this.spline, currentT, direction, maxAngle); if (newSpline == null) { return; } this.MoveSpline(newSpline); }
public void SetSplineGroup(SplineGroup group) { this.splineGroup = group; this.spline = group.GetClosestSpline(this.transform.position); //Debug.LogError("SetSplineGroup " + this.name + " spline=" + spline); }