private void OnDrawGizmos() { if (gizmo == null) { gizmo = new CurveFly(myCurveRoot.transform); } gizmo.RefreshTransforms(1f); if ((gizmo.myPoints.Length - 1) % 2 != 0) { return; } int accur = 50; Vector3 prevPos = gizmo.myPoints[0].position; for (int c = 0; c < accur; c++) { float currTime = c * gizmo.GetDuration() / accur; Vector3 currPos = gizmo.GetPositionAtTime(currTime); float mag = (currPos - prevPos).magnitude * 2; Gizmos.color = new Color(mag, 0, 0, 1); Gizmos.DrawLine(prevPos, currPos); Gizmos.DrawSphere(currPos, 0.01f); prevPos = currPos; } }
// Start is called before the first frame update void Start() { myAudioSource = GetComponent <AudioSource>(); curveFly = new CurveFly(myCurveRoot.transform); if (myAutoStart) { RefreshTransforms(mySpeed); FollowCurve(); PlayUpSound(); } }