tidewaterSwim.package
This package holds more than this page lists. See all of its files in its world.
README.md
Swimmer
Lets a character swim. Goes on the body a scene's PlayerPrototype names (next to the built-in CharacterController, which the built-in humanoid avatar brings), or on an NPC body that walks on a CharacterController. It adds climbKit's ClimbMover to the body in play when it is missing, for climbing out.
body.component.add("tidewaterSwim.Swimmer", { feel = "arcade" })
What it does
| State | When | What happens |
|---|---|---|
walking | feet dry (water under 0.15 m) | the controller as it was |
wading | 0.15 m up to the feel's swimDepth | the controller walks slower the deeper it is (down to wadeMin of its speed), sprint fades out |
swimming | deeper than swimDepth, or falling in | the controller is switched off and this component moves the body: camera-relative strokes on the surface, collision by capsule sweep |
treading | swimming with no input for 0.35 s | upright, head out, bobbing |
diving | under the surface (dive control held, or below floating depth) | swim down and up, buoyancy brings it back |
climbing | pushing into a quay edge or a ladder at the surface | climbKit's tryMantle (quay, ledge up to its reach) or tryClimb (a wall marked climbable, such as a ladder) runs the move; walking up a bank is plain wading out |
Water is read with Physics.water, so any water works: Tidewater kinds, an engine Water component, terrain lakes and rivers. A current (velocity of the water) carries the swimmer by the feel's current share.
Fields
| Field | Default | |
|---|---|---|
feel | arcade | arcade, realistic, heavy, cartoon (numbers in the package README), or one registered with tidewaterSwim.feels |
climbOut | true | climb out at quays and ladders through climbKit |
breathLimit | true | use the feel's breath (realistic 45 s, heavy 25 s; arcade and cartoon have none) |
splashes | true | splash on entry and ripples while swimming, through Tidewater FX when installed |
cameraKick | true | a light camera shake on a hard entry, through juiceKit when installed |
poseNode | "" | the visual the procedural pose tips; empty finds the child under the body's facing anchor |
swimClip / treadClip | none | the avatar's own clips; played with ClipPlayer instead of the procedural pose |
Telemetry: state (synced), vertical (-1/0/1, synced), breath (0..1, synced), depth, speed, climbHow.
Events (synced)
onStateChanged { from, to }, onEnterWater { speed }, onClimbOut { how } (quay, ladder, bank), onOutOfBreath {} (the game decides the cost).
Methods
setFeel(name), getState(), isSwimming().
Controls
The player's own move, jump and sprint (the controller's input map), plus tidewaterSwim.swim (swimUp, swimDown) held only while in deep water. When a controlsKit scheme is live, its move, jump/ascend, crouch/descend and sprint/dash are read instead. NPCs: the controller's input bus (inputX/inputZ as the stroke, inputJump up).
Multiplayer
Only the peer that owns the body moves it; the body position replicates as usual. state and vertical are synced, and every peer draws the swim pose, the splash and the ripples from them.