Class FloatingBoats
Boats on the water: moored ones riding the tide at their harbour (and settling on the mud, heeled over, when it goes out from under them), and ships under way along the scene's sea lanes, solid, with a deck a player can stand on and be carried by (2026-10-12: "We need docks…, accurate ships and boats"; "We should have ships floating out in the ocean too?"; "Solid sailing ships needs to be done.").
[DisallowMultipleComponent]
public sealed class FloatingBoats : MonoBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourFloatingBoats
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Remarks
Why not props. The POI props are static and instanced; the sea is not (SeaTide moves it up to a few metres), so a hull fixed at mean sea level would stand clear of the water at low tide and be swamped at high.
A moored boat collides (2026-10-12: "Add collision to floating boats so we don't swim through them"). Its root, which the server keeps, carries its hull's collider and moves only with the tide: its level is worked out from WaterQuery at the synced tick, on the server and every client alike and to the millimetre, so a prediction meets the hull where the server does (and the tide moves it a tenth of a millimetre a second). Its bob and roll on the swell are its client-only visual child's alone.
A ship under way collides too, and its pose is a pure function of the synced tick. Each ship's root (kept by
the server, its hull's collider on it, no NetworkObject) is placed on its lane by CourseAt(Lane, in Sailing, double) from
tick × TickDelta and on the water by WaterQuery at the same tick. Nothing about it is ever sent:
the server and every client already agree on the tick, so they agree on the hull. That is the whole reason not to
make it a KCCPlatform: a platform is STEPPED (its next pose depends on its last), so FishNet has to
reconcile it to every observer every tick and roll it back under a replaying rider, which costs a forwarded
NetworkObject, a reconcile per observer per tick, and an observer range — and a ship is seen from kilometres off,
sails for an hour, and twelve of them share a scene. A pose that is a function of the tick needs none of it: to
"roll the hull back" for a replayed tick is simply to evaluate the function at that tick.
When it is posed. On every peer, before anything simulates a tick: in TimeManager.OnPreTick for the live
tick, in PredictionManager.OnPreReplicateReplay for each tick a client replays (so a replayed ground probe meets
the deck where it stood on that tick, as a forwarded platform's would), and again in OnPostReconcile to stand it
back at the live tick before OnTick runs; then Physics.SyncTransforms, because the project runs with
automatic transform sync off and a moved collider is otherwise invisible to queries until the next simulation. The
tick it is posed at is the SYNCED tick the server runs that input on — the server's own Tick, a client's
LocalTick mapped through the last reconcile's pairing (WeatherExposureTick) — which is the same
tick a rider's replicate reads (KCCController.WaterTick), live and in replay.
Riders are carried through the same seam as a platform's (KinematicCharacterMotor.SetPlatformVelocity,
the attached-rigidbody carry): TryGetCarry(Scene, uint, double, Vector3, float, out Vector3, out float, out ShipRef) gives the velocity that keeps a deck point under the rider's
feet from the last tick's pose to this one's — a rigid motion, so the 180° swing at anchor carries a rider round with
the deck — and the yaw the hull turned through between the two, which the motor puts on the rider's facing as KCC
does an attached PhysicsMover's rotation; both only to a stably grounded character. Who is aboard is decided
spatially, again from the tick (feet over the deck in the last tick's frame, confirmed by a ray down onto this hull's
own collider), never from a trigger volume or the motor's ground collider, neither of which a reconcile restores.
A rider's camera turns with the ship (the owner's only, a presentation of the drawn hull: see TryGetDrawnYaw(in ShipRef, out float)), as KCC's camera turns with a PhysicsMover. It has to: a character facing the camera (the shipped orientation) takes its facing from the camera's rotation in its input every tick, so a camera fixed in the world would hold the rider's facing fixed in the world whatever the motor did. Being input, the turned camera reaches the server and every replay as it is, so nothing about it can diverge.
Drawn on the client from the same function at a fractional tick, VisualInterpolationTicks behind the simulated one: the lag the owner's own character is drawn at (its NetworkObject smoother), so a rider and the deck under them are drawn at the same moment and do not slide against each other. Bob, roll and the wind's heel are the drawn hull's alone; the collider never bobs.
A ship beyond the scene's edge (waiting at a lane end that is open sea) is hidden and its collider and obstacle are switched off: nothing can run into a ship nobody can see.
Airships (a cloud world's, 2026-10-14: "flying ships") are the same ships on lanes through the air (Airborne): a lane point's y is the ship's own height, climbing and descending between landing stages, and the root's frame has the deck at y 0 instead of the waterline. At a port end such a lane holds the ship still alongside its stage and swings it only at the end of its wait (BerthSwing). Everything else (the pose from the tick, the carry, the solid hull) is the ships' own.
Built by the cut: a harbour's (PointOfInterestHarbour), the sea lanes' (PointOfInterestSeaTraffic) and the sky's (PointOfInterestSkyTraffic), each on an object the server keeps, each boat's drawn hull under a ClientOnlyObject.
Fields
DeckHeadroom
How far over the hull's highest point a rider's feet may be and still be aboard, metres.
public const float DeckHeadroom = 0.5
Field Value
DeckMargin
How far past the hull's bounds a rider's feet may stand and still be aboard, metres (the gunwale's width).
public const float DeckMargin = 0.3
Field Value
RiderAboveWaterline
The lowest a rider's feet stand above the waterline in the hull's frame, metres: a swimmer alongside is never aboard.
public const float RiderAboveWaterline = 0.2
Field Value
ShoreMarkName
The object each hull mark is drawn from, a child of the hull renderer it copies.
public const string ShoreMarkName = "Shore Mark"
Field Value
ShoreMarkShaderName
The FishMMO Water plugin's hull mark (FishHullShoreMark.shader): drawn over a hull's own pixels, it tells the sea's shore pass to leave them alone. Found by name, as this assembly does not reference the plugin; the scene's WaterShore references the shader so a build includes it.
public const string ShoreMarkShaderName = "FishMMO/Water/Hull Shore Mark"
Field Value
SolidReach
How far past its own length a ship under way keeps its collider placed for a character, metres (PoseShips(uint, double)): on the server any character in the scene, on a client the character it predicts and its camera. Beyond that nothing can touch the hull before the next tick poses it again, so its collider is switched off and its root left where it was, rather than moved and re-synced every tick for nobody. Ample against a tick's travel (under a metre) and against a client's camera, its rain shelter map and its replays.
public const float SolidReach = 64
Field Value
VisualInterpolationTicks
How many ticks behind the simulated hull the drawn one is: the owner's own character's interpolation
(_ownerInterpolation on the playable prefabs, and a platform deck's smoother), so a rider and the deck under
them are drawn at the same moment. Pinned to PlatformRiderSmoothingTests.InterpolationTicks; never give the
deck a different lag from the rider (see the rider-smoothing notes on issue #228).
public const int VisualInterpolationTicks = 1
Field Value
Properties
Airborne
True for airships: see the field's notes.
public bool Airborne { get; }
Property Value
Lanes
Set by the cut. inAir for airships (Airborne).
public IReadOnlyList<FloatingBoats.Lane> Lanes { get; }
Property Value
MooredCount
public int MooredCount { get; }
Property Value
SailingCount
public int SailingCount { get; }
Property Value
Methods
Configure(Moored[], Lane[], Sailing[], bool)
public void Configure(FloatingBoats.Moored[] boats, FloatingBoats.Lane[] ways, FloatingBoats.Sailing[] ships, bool inAir = false)
Parameters
CourseAt(Lane, in Sailing, double)
Where a ship is on its lane at seconds of the shared clock (y the lane's sea level, which the
caller replaces with the water's at the tick): the out-leg with its port easing, the wait at the far end (in port,
swinging 180° to its cable; at the scene's edge, out of sight), the leg back, and the wait at the start. Pure: the
same seconds give the same pose on every peer.
public static FloatingBoats.ShipPose CourseAt(FloatingBoats.Lane lane, in FloatingBoats.Sailing ship, double seconds)
Parameters
laneFloatingBoats.LaneshipFloatingBoats.Sailingsecondsdouble
Returns
Covered(float, float, float)
The share of a leg's distance covered at u of its time, at full speed but for a ramp up over
the first easeStart of the time and down over the last easeEnd: out of
1 − (easeStart + easeEnd) / 2 at the leg's end.
public static float Covered(float u, float easeStart, float easeEnd)
Parameters
Returns
IsUnderWay(Transform)
True when t is (under) a ship under way: it moves, so the NavMesh bake must never take its collider
as ground or wall where the cut happened to leave it.
public bool IsUnderWay(Transform t)
Parameters
tTransform
Returns
LaneArea(Lane)
A lane's points' extent across the ground (x, z as the rect's x, y); empty at the origin for a lane with none.
public static Rect LaneArea(FloatingBoats.Lane lane)
Parameters
laneFloatingBoats.Lane
Returns
- Rect
MayReach(Rect, float, Vector3)
Whether a rider at rider can be within reach of a point somewhere in
area (a lane's extent across the ground): false only when it is further than that from all of it.
public static bool MayReach(Rect area, float reach, Vector3 rider)
Parameters
areaRectreachfloatriderVector3
Returns
PointAt(Lane, float)
The lane's point along metres from its start.
public static Vector3 PointAt(FloatingBoats.Lane lane, float along)
Parameters
laneFloatingBoats.Lanealongfloat
Returns
- Vector3
RoundSeconds(Lane, in Sailing)
How long one whole round of ship on lane takes, seconds, as
CourseAt(Lane, in Sailing, double) sails it: out, the wait at the far end, back, the wait at the start. Zero for a lane it
cannot sail.
public static double RoundSeconds(FloatingBoats.Lane lane, in FloatingBoats.Sailing ship)
Parameters
laneFloatingBoats.LaneshipFloatingBoats.Sailing
Returns
SecondsAt(double, double)
The shared clock's seconds at a synced tick: the one time base every peer agrees on, with no timeline to wait for.
public static double SecondsAt(double tick, double tickDelta)
Parameters
Returns
SwingShare(float, float, float)
How far through its 180° swing a ship waiting elapsed seconds of a dwell is,
0..1. With no berthSwing (a sea lane) it swings through the whole wait; with one it lies still
until the last berthSwing seconds (at most the whole wait) and swings then.
public static float SwingShare(float elapsed, float dwell, float berthSwing)
Parameters
Returns
SyncTick(bool, uint, uint, uint, uint, uint)
The synced tick a peer simulates its localTick at: the server's own tick on the server; on a
client, its local tick mapped through the last reconcile's (client, server) pairing — the same mapping
(Resolve(bool, uint, uint, uint, uint, uint)) a rider's replicate uses for the
water, so the ships are posed at exactly the tick the rider reads them at, live and in replay.
public static uint SyncTick(bool isServer, uint serverTick, uint clientSyncTick, uint clientStateTick, uint serverStateTick, uint localTick)
Parameters
isServerboolserverTickuintclientSyncTickuintclientStateTickuintserverStateTickuintlocalTickuint
Returns
TryCarry(in ShipPose, in ShipPose, Bounds, Vector3, float, float, out Vector3, out float)
TryCarry(in ShipPose, in ShipPose, Bounds, Vector3, float, out Vector3, out float) with the lowest a rider's feet may stand in the hull's frame and still be aboard: RiderAboveWaterline on the water, negative infinity for an airship (nothing but its own hull's bounds, as nobody swims alongside it).
public static bool TryCarry(in FloatingBoats.ShipPose before, in FloatingBoats.ShipPose now, Bounds deck, Vector3 rider, float delta, float lowest, out Vector3 velocity, out float turn)
Parameters
beforeFloatingBoats.ShipPosenowFloatingBoats.ShipPosedeckBoundsriderVector3deltafloatlowestfloatvelocityVector3turnfloat
Returns
TryCarry(in ShipPose, in ShipPose, Bounds, Vector3, float, out Vector3)
The velocity that carries a rider standing at rider (its feet, where the last tick left it) with
a hull that moved from before to now over delta seconds:
the deck point under its feet, moved rigidly. False (and zero) when the rider is not over this deck — outside its
bounds in the last tick's frame, or below the waterline, as a swimmer alongside is — or the ship is hidden.
public static bool TryCarry(in FloatingBoats.ShipPose before, in FloatingBoats.ShipPose now, Bounds deck, Vector3 rider, float delta, out Vector3 velocity)
Parameters
beforeFloatingBoats.ShipPosenowFloatingBoats.ShipPosedeckBoundsriderVector3deltafloatvelocityVector3
Returns
TryCarry(in ShipPose, in ShipPose, Bounds, Vector3, float, out Vector3, out float)
TryCarry(in ShipPose, in ShipPose, Bounds, Vector3, float, out Vector3), and the yaw the hull turned through, degrees about +y (Turn(in ShipPose, in ShipPose)): what the rider's facing turns by, so it keeps its bearing on the deck as its feet keep their place. Zero when not carried.
public static bool TryCarry(in FloatingBoats.ShipPose before, in FloatingBoats.ShipPose now, Bounds deck, Vector3 rider, float delta, out Vector3 velocity, out float turn)
Parameters
beforeFloatingBoats.ShipPosenowFloatingBoats.ShipPosedeckBoundsriderVector3deltafloatvelocityVector3turnfloat
Returns
TryGetCarry(Scene, uint, double, Vector3, float, out Vector3, out float, out ShipRef)
The carry of whichever ship under way in scene a rider at rider stands on,
at the synced tick it is simulating (a rider's KCCController.WaterTick, the tick the
ships are posed at, live and in replay): the velocity, the yaw the hull turned through this tick, degrees, and
which ship it is. Zero, default and false, aboard none.
public static bool TryGetCarry(Scene scene, uint tick, double tickDelta, Vector3 rider, float delta, out Vector3 velocity, out float turn, out FloatingBoats.ShipRef ship)
Parameters
sceneScenetickuinttickDeltadoubleriderVector3deltafloatvelocityVector3turnfloatshipFloatingBoats.ShipRef
Returns
TryGetDrawnYaw(in ShipRef, out float)
The yaw ship's drawn hull shows this frame, degrees: worked out at the same fractional tick
FishMMO.Shared.FloatingBoats.LateUpdate() draws it at. What a rider's camera turns by from one frame to the next, so the view swings
with the deck the rider sees (drawn at the rider's own lag) rather than with the collider a few ticks ahead of it.
False for no ship, or one out of sight.
public static bool TryGetDrawnYaw(in FloatingBoats.ShipRef ship, out float yaw)
Parameters
shipFloatingBoats.ShipRefyawfloat
Returns
Turn(in ShipPose, in ShipPose)
The yaw a hull turned through from before to now, degrees about +y, the short
way round: the heading comes from an arctangent that wraps at ±180°, and a round's two swings add a whole turn, so
the plain difference can be a full turn out.
public static float Turn(in FloatingBoats.ShipPose before, in FloatingBoats.ShipPose now)
Parameters
beforeFloatingBoats.ShipPosenowFloatingBoats.ShipPose
Returns
Turned(Vector3, float)
A direction turned by turn degrees about +y in Unity's sense (Quaternion.Euler(0, turn, 0)),
as a deck turns everything standing on it: the rotation ToWorld(Vector3) puts between two poses.
public static Vector3 Turned(Vector3 direction, float turn)
Parameters
directionVector3turnfloat
Returns
- Vector3