CMCharacter Modules 0.1.0

Swim

Kind: State · Add Component: Character Modules > States > Swim

Swims in deep water, up and down. Water breaks a fall and adds a third dimension to the level.

Swimming in deep water: no ground, the view chooses the direction, Jump swims up, and jumping at the surface climbs out. Water breaks a fall and opens a level's third dimension.

Inspector
▼Swim⋮
CharacterCharacter (Character Motor)
Swim Depth0.6
Leave Depth0.45
Max Speed3.5
Acceleration4
Friction2
Sink Speed0.6
Turn Rate540
Water Jump Speed6
The Swim component in the Inspector, with its defaults.
Origin. Quake (1996) swims where the player looks; Super Mario 64 (1996) and Tomb Raider (1996) swim in 3D too.

How it works

The Swimming mode: runs deep water.

Swimming, when the water reaches the chest: no gravity, water friction, and movement in three dimensions toward where the view points. Jump swims up, crouch swims down, and with no input the character sinks slowly. Pressing jump near the surface throws the character up out of the water, so it can climb onto a ledge (a water jump). With Body Facing on States, the body turns toward where it swims.

Hooks called: ISpeedScale.

Combine it

  • Needs: Volume Sensor. The Inspector warns while one is missing.
  • Priority 30: when several states could run, the highest priority wins (see How modules combine).
  • Used by the presets: Arena Shooter, Competitive Shooter, Surf, Retro Platformer, Modern Platformer, Traversal Adventure.

Properties

PropertyDescriptionRangeDefault
CharacterThe character this module belongs to. Drag its Character Motor here.None
Swim DepthWater depth, as a fraction of the character's height, at which swimming starts.0.1 to 10.6
Leave DepthSwimming stops below this depth, as a fraction of height (less than the start depth, so it does not flicker).0.05 to 10.45
Max SpeedTop swimming speed, m/s.0 or more3.5
AccelerationHow quickly input changes the swimming velocity, per second.0 or more4
FrictionHow quickly the water slows the character down, per second.0 or more2
Sink SpeedSinking speed with no input, m/s.0 or more0.6
Turn RateHow fast the body turns toward where it swims, degrees per second (when the states turn the body).0 or more540
Water Jump SpeedUpward speed of a water jump, m/s.0 or more6

Additional resources