Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GameObject gameObject = new GameObject("River");
- SplineContainer splineContainer = gameObject.AddComponent<SplineContainer>();
- splineContainer.Splines = null;
- //Create a basic spline with a wiggly shape
- int knots = 5;
- float amplitude = 2f;
- float length = 50f;
- Spline spline = new Spline(knots, false);
- for (int i = 0; i <= knots; i++)
- {
- float t = (float)i / (float)knots;
- BezierKnot knot = new BezierKnot();
- knot.Position = new Vector3(Mathf.Sin(t * knots * 2f) * amplitude, 0f, (t * length) - (length * 0.5f));
- spline.Add(knot, TangentMode.Linear);
- }
- //Automatically recalculate tangents
- spline.SetTangentMode(new SplineRange(0, spline.Count), TangentMode.AutoSmooth);
- splineContainer.AddSpline(spline);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement