Tidewater: Oceans, Lakes, Rivers, Waterfalls, Swimming and Splashes Water Kit (fork)
README.md
tidewaterSwim 1.0.0: let the player swim
Swimming for any Zero game. The player wades (slower the deeper the water gets), swims on the surface, treads water when idle, dives under and swims down and up, and climbs back out at a quay edge, a ladder or a riverbank. A river's current carries a swimmer downstream. Keyboard, gamepad and touch. Multiplayer.
It works on any water the engine knows: every Tidewater kind (lake, pool, river, ocean, ...), an engine Water component, a terrain's lakes and rivers, anything Physics.defineWater defines. It reads the water through Physics.water, so the water kit is not required. Tidewater FX (splash and ripples), juiceKit (a light camera kick on a hard entry) and controlsKit (its schemes) are used when the world has them and left alone when it does not.
Install (a few minutes)
- In the editor's ZeroMind panel search for tidewaterSwim and press Install (or
zero zeromind installAsset <guid>in the agent shell). climbKit installs with it (it runs the pull-up onto a quay and the ladder climb). - In your scene's
build.luau, after the line that makes the player prototype'sbody, add one line:
body.component.add("tidewaterSwim.Swimmer", { feel = "arcade" })
- Press Play and walk into water. That is all: no new input setup, no water wiring.
For a quay you can climb out onto, any collider edge up to about 2.3 m above the swimmer's feet works (a quay top up to about 1 m above the water). For a ladder up a taller wall, mark the ladder's collider (or a parent) climbable: ladder.attribute.set("climbable", true). A bank is any slope the character can walk on.
In the water, never in the ground
- Depth is measured against the real ground. The Swimmer starts swimming only where the water column, from the surface down to the first collider under it, is deeper than the feel's swim depth, and it stands up and walks out the moment the bed under it rises above that. Jumping into knee-deep water lands you on the bed, wading.
- Land is never water. Where a landscape (a terrain's
HeightfieldCollider) stands above a water's surface, that spot is land to the Swimmer, even when the water's own region reaches in under the bank. - Never inside a landscape. A body found under a landscape (pushed, or fallen in before the ground was there) is put back on top of it within 0.2 s and walks on.
- Never falling through the world. A landscape cooks a moment after its scene loads. A dry body with nothing under it at all is held where it stands (up to 30 s) until the ground arrives, then walks on it.
- Tidewater lakes and ponds that use a landscape as their bed (
options = '{"bed":false}') also declare their physics water only where that landscape lies below the surface, so boats and anything else readingPhysics.wateragree.
The four feels
feel picks one; component.get("tidewaterSwim.Swimmer"):setFeel("heavy") switches live.
| arcade | realistic | heavy | cartoon | |
|---|---|---|---|---|
| swim speed (m/s, surface) | 3.2 | 1.4 | 0.9 | 4.0 |
| sprint multiplier | 1.5 | 1.6 | 1.3 | 1.6 |
| dive / rise speed (m/s) | 2.4 | 1.0 | 0.8 | 3.2 |
| acceleration / drag (1/s) | 6 / 3 | 2.5 / 1.8 | 1.5 / 1.2 | 9 / 4 |
| buoyancy under water (m/s²) | 0.8 | 0.35 | -0.15 (sinks) | 1.6 |
| swim depth (starts swimming, m) | 1.2 | 1.3 | 1.4 | 1.1 |
| wading speed left at that depth | 45% | 35% | 25% | 55% |
| strokes per second | 1.4 | 0.9 | 0.6 | 2.2 |
| surface bob / tread bob (m) | 0.05 / 0.04 | 0.04 / 0.06 | 0.025 / 0.08 | 0.12 / 0.10 |
| body lean while swimming | 72° | 80° | 60° | 85° |
| climb out (quay pull-up, s) | 0.35 to 0.5 | 0.6 to 0.9 | 0.9 to 1.3 | 0.25 to 0.35 |
| ladder speed (m/s) | 2.2 | 1.2 | 0.8 | 3.0 |
| share of a river current | 0.6 | 1.0 | 1.2 | 0.5 |
| breath under water | none | 45 s | 25 s | none |
Measured in play
Measured on the Lakeside scene (2026-11-22) with real input driven through the engine's input simulator, on the built-in player (walk 2.5 m/s), at about 20 to 25 fps in a headless test client. Speeds count only frames shorter than 0.1 s, since the Swimmer caps a frame's step at 0.1 s.
| arcade | realistic | heavy | cartoon | |
|---|---|---|---|---|
| walking, dry ground (m/s) | 2.50 | 2.50 | 2.50 | 2.49 |
| wading, ankle deep (about 0.23 m) | 2.37 | 2.39 | 2.40 | 2.40 |
| wading, knee deep (about 0.5 m) | 2.05 | 1.93 | 1.92 | 2.05 |
| wading, waist deep (about 0.95 m) | 1.44 | 1.38 | 1.06 | 1.54 |
| swim speed, surface (m/s) | 3.20 | 1.39 | 0.86 | 4.00 |
| swim speed, sprinting (m/s) | 4.80 | 2.16 | 1.14 | 5.68 |
| treading: head above the surface (m) | 0.21 | 0.19 | 0.24 | 0.20 |
| treading: bob, top to bottom (m) | 0.04 | 0.06 | 0.07 | 0.08 |
| dive, swimming down (m/s) | 2.38 | 0.98 | 0.75 | 3.19 |
| swimming up (m/s) | 2.38 | 0.83 | 0.51 | 3.20 |
| breath under water | no limit | 37 to 45 s (8% lost in 3 s; the synced value moves in 2% steps) | 24 s | no limit |
| climb out at the dock end (s, from the water to standing) | 0.61 | 0.94 | 1.28 | 0.43 |
Gamepad (left stick, A, B) and touch (on-screen stick, Swim up and Dive buttons) were driven the same way and move the swimmer like the keyboard: 3.2 m/s on the stick (arcade), 2.4 m/s down on B, 2.3 m/s up on A, about 1.9 m down in 0.9 s on Dive and 1.9 m up in 0.9 s on Swim up. Real phones, tablets and physical gamepads were not tested: only the engine's simulated devices.
Two players (the editor's client and a second client in the same Lakeside session): the second player sees the swimmer's state (swimming, treading) as the owner does, at the same spot to within about 0.1 m, with the same treading tilt.
Re-verified on Lakeside after the ground fixes (four fresh plays, arcade unless named): every start on the dock, walking; wading 2.45 m/s on dry deck, 2.08 at 0.5 m, 1.45 at 0.96 m, then swimming at 3.20; swimming back to the shore stands up and walks out at 0.12 m depth; climb out at the dock end 0.54 s (realistic 0.93, heavy 1.25, cartoon 0.35); over the pool's coping 0.49 to 0.53 s; onto the dock's side with forward + Swim up in about 0.5 s (just pushing swims under the deck, which has 60 cm of air under it); a body pushed into the meadow or under the lake bed is back on top within 0.15 s. Gamepad and touch as above (3.20 m/s, dive 2.35 m/s, up 2.29 m/s). The web build was not tested: nothing in the Swimmer is native-only (rays, capsule casts, input maps and components only).
Your own: require("tidewaterSwim.feels").register("otter", { swimSpeed = 5, breath = 0 }) (missing numbers come from arcade).
Controls
| Keyboard + mouse | Gamepad | Touch | |
|---|---|---|---|
| swim (camera-relative) | WASD / arrows | left stick | the on-screen stick |
| swim faster | Shift (sprint) | the sprint button | the sprint button |
| swim up / climb out | Space | A (south) | Swim up button |
| dive / swim down | Ctrl | B (east) | Dive button |
| climb out at a quay or ladder | swim into it (or Space against it) | push into it (or A) | push into it (or Swim up) |
| on a ladder | W / Space climbs on, Ctrl climbs down | stick / A climbs on, B down | stick / Swim up climbs on, Dive down |
| walk out at a bank | swim toward it | push toward it | push toward it |
Up and Dive come from the package's own tidewaterSwim.swim input map, live only while the player is in deep water, so they never take Space or Ctrl from your game on land. When a controlsKit scheme is live, its own actions are read instead: move, jump or ascend (up), crouch or descend (down), sprint or dash, with controlsKit's touch controls.
For game code
local sw = body.component.get("tidewaterSwim.Swimmer")
sw.events.onStateChanged:connect(function(e) print(e.from, "->", e.to) end)
sw.events.onOutOfBreath:connect(function() takeDamage(10) end)
sw.events.onClimbOut:connect(function(e) print("climbed out at a", e.how) end) -- quay | ladder | bank
print(sw.state, sw.breath, sw.depth, sw:isSwimming())
Types: require("tidewaterSwim.feels") exports SwimFeelName, SwimState (walking | wading | swimming | treading | diving | climbing) and SwimFeel.
Animation
When the avatar has swim clips, set swimClip (and treadClip) and they loop while swimming and treading. Otherwise (the built-in humanoid has none) the body is tipped toward horizontal with a stroke roll over its walk cycle, upright and bobbing while treading, nose down while diving and up while rising.
Multiplayer
Put the Swimmer on the player prototype's body and every player who joins gets it. Each peer drives only its own player's body; the body's position replicates as usual, state, vertical and breath are synced, and every peer draws the swim pose, the splash and the ripples for every swimmer from them.
Known limits
- Up is world +Y: no swimming in a
GravityField. - The procedural pose tips the whole body; arms and legs play the walk cycle, not a real stroke. Give the avatar swim clips for a true crawl.
- Climbing out needs climbKit's reach: a quay top more than about 1 m above the water needs a ladder (marked climbable).
- The muffled sound and the fog under water are the water kit's job (Tidewater's underwater pass), not this package's.
- Breath runs out with an event only: the game decides what drowning costs.
See also
- Tidewater (
tidewaterpackage), the water for Zero games: How to add water to my game, How to add a lake or pond, How to add a swimming pool or hot spring, How to add a river that carries things downstream, and Example: build a small harbour level, which puts a Swimmer on the player beside a pier with a climbable ladder. The Tidewater showcase scene (scenes/showcase.scene/build.luau) usesfeel = "arcade".