private void ShowNormals() { Handles.color = Color.red; Vector3 point = spline.GetPoint(0f); Handles.DrawLine(point, point + spline.GetNormal(0f) * directionScale); int steps = stepsPerCurve * spline.CurveCount; for (int i = 1; i <= steps; i++) { point = spline.GetPoint(i / (float)steps); Handles.DrawLine(point, point + spline.GetNormal(i / (float)steps) * directionScale); } }
//public bool distanceBased = false; private void Awake() { path = GetComponent <BezierSpline>(); if (frequency <= 0 || items.Length == 0 || path == null) { return; } int index; float step = 1f / ((float)frequency + 1f); Vector3 pos; Vector3 localDir; GameObject go; for (int i = 1; i <= frequency; i++) { index = Random.Range(0, items.Length - 1); pos = path.GetPoint(i * step); if (localOffset) { localDir = path.GetNormal(i * step); go = Instantiate(items[index], pos + (heightOffset * localDir), items[index].transform.rotation, transform); } else { go = Instantiate(items[index], pos + new Vector3(0, heightOffset, 0), items[index].transform.rotation, transform); } //Turns object to go in the direction of the bezier curve if (curveRotation) { go.transform.forward = path.GetDirection(i * step); } } }