Waves
The wave function: Gerstner waves, shared by the renderer (client) and the physics (both sides). It is deterministic in the settings, the weather state and server time, so a height sampled on the server matches the surface a client sees.
Each weather compiles to a set of six waves plus its look. The sea at a point is a weighted sum of whole sets (zones cross-fading at their rims, the global weather for the rest, and two sets while a weather is transitioning), never a blend of wave parameters.
Properties
SeaLevel
Waves.SeaLevel: numberThe SeaLevel setting, cached.
Sets
Waves.Sets: {[string]: Set}Compiled wave sets by weather name.
Version
Waves.Version: numberIncrements every time the sets are recompiled.
Functions
MeshAvailable
Waves.MeshAvailable() → boolean
Whether this experience may create EditableMeshes. When it may not, the sea falls back to a
flat surface at SeaLevel (as if FlatSea were on) and the wave mesh is never built.
SetLocalFlat
This item only works when running on the client. ClientWaves.SetLocalFlat(on: boolean) → ()Makes this client's sea flat (heights, swimming and the tint follow the flat surface it is drawing) without touching the setting. The renderer turns it on while a device cannot hold the wave mesh and off again once it can.
Refresh
Waves.Refresh() → ()Recompiles every weather into wave sets from the current settings and weather state. Runs automatically whenever a setting or the weather changes.
RefreshObstacles
Waves.RefreshObstacles() → ()Re-reads every OceanObstacle in the workspace. Runs twice a second on its own.
ObstaclesNear
Waves.ObstaclesNear(x: number?,z: number?,radius: number?) → {any}Obstacles whose calming ring touches the circle (x, z, radius); with no arguments, all of them.
Damp
The wave multiplier at (x, z) from the given obstacles: 1 in open water, down to
1 - OceanCalmness against an obstacle, easing across its shore ring.
Time
Waves.Time() → numberThe synced wave clock: server time times TimeScale, or 0 while StaticWaves is on.
ZonesNear
Waves.ZonesNear(x: number?,z: number?,radius: number?) → {any}Scripted weather zones whose disc touches the circle (x, z, radius); with no arguments, all of them.
IsBlending
Waves.IsBlending(now: number--
workspace:GetServerTimeNow()
) → booleanTrue while the global weather is mid-transition.
Gather
Waves.Gather(x: number,z: number,now: number--
workspace:GetServerTimeNow()
) → number
Fills Waves.LayerSets and Waves.LayerWeights with the wave sets that apply at (x, z) and
returns how many there are. The weights sum to 1.
Displace
Waves.Displace(x: number,z: number,t: number?,--
wave clock (default: now)
now: number?--
server time (default: now)
) → (number,--
X offset
number,--
Y offset
number--
Z offset
)
Displacement of the surface point that rests at (x, z): how far it has been pushed along X, up
along Y and along Z. Zero everywhere while FlatSea is on.
Height
Waves.Height(x: number,z: number,t: number?,--
wave clock (default: now)
now: number?--
server time (default: now)
) → number
World Y of the surface above (x, z). Gerstner waves move points sideways, so this iterates to find
the rest point that lands on (x, z); the answer is within a quarter stud. Ocean:GetHeight calls this.
LookNumber
Waves.LookNumber(name: string,x: number,z: number) → number
One numeric weather setting blended at a point, for example Waves.LookNumber("SplashRate", x, z).
"MaxAmp" gives the tallest possible crest there.
SelfTest
Waves.SelfTest() → string
Checks that Waves.Height inverts Waves.Displace and that layer weights sum to 1. Run it from the
command bar: require(game.ReplicatedStorage.Ocean.Waves).SelfTest().