Log inGet started
Package

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

StateWhenWhat happens
walkingfeet dry (water under 0.15 m)the controller as it was
wading0.15 m up to the feel's swimDepththe controller walks slower the deeper it is (down to wadeMin of its speed), sprint fades out
swimmingdeeper than swimDepth, or falling inthe controller is switched off and this component moves the body: camera-relative strokes on the surface, collision by capsule sweep
treadingswimming with no input for 0.35 supright, head out, bobbing
divingunder the surface (dive control held, or below floating depth)swim down and up, buoyancy brings it back
climbingpushing into a quay edge or a ladder at the surfaceclimbKit'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

FieldDefault
feelarcadearcade, realistic, heavy, cartoon (numbers in the package README), or one registered with tidewaterSwim.feels
climbOuttrueclimb out at quays and ladders through climbKit
breathLimittrueuse the feel's breath (realistic 45 s, heavy 25 s; arcade and cartoon have none)
splashestruesplash on entry and ripples while swimming, through Tidewater FX when installed
cameraKicktruea 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 / treadClipnonethe 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.