Documentation is a draft
This asset is pending release
Stylized Water 3 - River Modeler (Extension)
4.Scripting
Events
RiverModeler.onPreRebuildRiver += OnRiverRebuild;
RiverModeler.onPostRebuildRiver += OnRiverRebuild;
Sampling the river surface
Generally, you can sample the same spline used by a river to get its position/direction/normal using Spline.Evalutate(t);. But the River Modeler component contains a helper function that simplifies this:
RiverModeler.FindNearestPointOnRiver(float3 worldPosition, out float3 point, out float3 direction, out float3 normal, out float t, float sampleDistance = 1f);
This is excellent to use for controlling particle effects, swimming behaviour or buoyancy physics!
Procedural Splines
If you’re looking to generate a spline from a set of points, that is certainly possible. Unity’s Splines API contains this function which can be used for it:
FitSplineToPoints(List<float3> positions, float errorThreshold, bool closed, out Spline spline);
If you have the Spline Extensions asset installed, you can use a multithreaded variant that’s x26 times faster
CreateSplineFromPoints.Execute(List<float3> positions, float errorThreshold, bool closed, out Spline spline, float3 up = default);
