Class SwimPose
How a swimmer is drawn in the water: how far it leans, how near the surface it counts as, where its body turns, and how it tips on a wave. The arithmetic behind CharacterAnimationController's procedural swim pose and the World Sim walker's figure, kept apart so both pose a swimmer the same way and the rules can be tested.
public static class SwimPose
- Inheritance
-
SwimPose
- Inherited Members
Remarks
Presentation only. The movement (KCCController) floats the capsule on the still water, a fixed depth under it, and never sees a wave. Nothing here feeds back into it.
Leans are degrees forward of upright, as a model's local pitch: 0 stands, 90 lies flat along the swim, past 90 dives. Unity turns +X pitch nose down (forward (0, 0, 1) goes to (0, −sin θ, cos θ)), so a nose-up tilt is negative.
Fields
HeadAboveWater
How high a swimmer's head joint (the base of the skull) is held over the water at the surface, metres: the water at the chin, mouth and eyes clear.
public const float HeadAboveWater = 0.05
Field Value
MaxWaveTilt
The steepest a wave tips a swimmer, degrees.
public const float MaxWaveTilt = 20
Field Value
PivotMetres
The height over the feet a swimmer turns about, metres: the chest.
public const float PivotMetres = 1.1
Field Value
Remarks
The capsule floats with its feet SwimFloatSubmersion of its 1.6 m height (1.2 m) under the still water, so a body turned about this point lies just under the surface (0.1 m). Turned about its feet, a level swimmer lay the whole 1.2 m down.
StrokeSpeed
The speed, m/s, by which a swimmer is fully into its stroke rather than treading.
public const float StrokeSpeed = 0.8
Field Value
SurfaceDepth
Depth below its float line, metres, down to which a swimmer still counts as fully at the surface.
public const float SurfaceDepth = 0.2
Field Value
SurfaceLean
Leaning forward swimming at the surface, degrees: head up and out, the legs trailing under it.
public const float SurfaceLean = 55
Field Value
TreadLean
Leaning forward treading water at the surface, degrees: all but upright.
public const float TreadLean = 8
Field Value
UnderDepth
Depth below its float line, metres, past which a swimmer counts as fully under.
public const float UnderDepth = 0.7
Field Value
WaveTiltShare
How much of a wave's slope a swimmer tips with: a body in the water follows the surface, but not all of it.
public const float WaveTiltShare = 0.6
Field Value
Methods
AlongSwim(float)
Leaning along a swim whose direction climbs elevationDegrees above level: flat (90) level,
past flat diving, up toward standing rising; never quite upside down or upright (10 to 170).
public static float AlongSwim(float elevationDegrees)
Parameters
elevationDegreesfloat
Returns
Elevation(Vector3)
The elevation of a velocity above level, degrees (−90 straight down to 90 straight up; 0 when still).
public static float Elevation(Vector3 velocity)
Parameters
velocityVector3
Returns
HeadLift(float, float, float, float)
How far to raise (or, negative, lower) a swimmer at the surface so its head joint stands
HeadAboveWater over the drawn water: the water's still line plus the wave there, against where the
head joint is with the body turned but not raised (both world heights). Scaled by surfaceShare,
so a swimmer going under eases back onto its capsule.
public static float HeadLift(float headAt, float stillWater, float wave, float surfaceShare)
Parameters
Returns
Lean(float, float, float)
How far forward of upright a swimmer leans: at the surface (surfaceShare 1) from treading
upright into a head-up stroke as its level speed (levelStroke, 0..1) grows; under, the lean
given (underLean: along its swim, or upright when still); between, the blend.
public static float Lean(float surfaceShare, float levelStroke, float underLean)
Parameters
Returns
Stroke(float)
How far into its stroke a swimmer going speed m/s is, 0 (treading) to 1.
public static float Stroke(float speed)
Parameters
speedfloat
Returns
SurfaceShare(float, float, float)
1 floating at the surface, 0 well under it, smoothly between: from how far the feet are below the line the
controller floats them at (stillWater less SwimFloatSubmersion
of capsuleHeight). The controller itself calls a swimmer at the surface within 0.35 m of it.
public static float SurfaceShare(float stillWater, float feetY, float capsuleHeight)
Parameters
Returns
TurnedHeight(float, float, float)
The height of a point on a body over its feet once the body is turned lean degrees forward
about PivotMetres: a point height up the body (stood upright) and
forward ahead of its axis.
public static float TurnedHeight(float height, float forward, float lean)
Parameters
Returns
WaveTilt(float, float, float, float, float, float, float, out float, out float)
How a wave tips a swimmer, degrees, from the drawn surface sampled ahead and
behind it (length metres apart) and to its right and
left (width apart): water rising ahead lifts its head (a negative pitch),
water higher on its right rolls its right side up (a negative roll, Unity turning +Z right side down). Scaled by
WaveTiltShare and surfaceShare, and kept within MaxWaveTilt.
public static void WaveTilt(float ahead, float behind, float length, float right, float left, float width, float surfaceShare, out float pitch, out float roll)