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
SwimCharacterCharacter (Character Motor)
Swim Depth0.6
Leave Depth0.45
Max Speed3.5
Acceleration4
Friction2
Sink Speed0.6
Turn Rate540
Water Jump Speed6
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
| Property | Description | Range | Default |
|---|---|---|---|
| Character | The character this module belongs to. Drag its Character Motor here. | None | |
| Swim Depth | Water depth, as a fraction of the character's height, at which swimming starts. | 0.1 to 1 | 0.6 |
| Leave Depth | Swimming stops below this depth, as a fraction of height (less than the start depth, so it does not flicker). | 0.05 to 1 | 0.45 |
| Max Speed | Top swimming speed, m/s. | 0 or more | 3.5 |
| Acceleration | How quickly input changes the swimming velocity, per second. | 0 or more | 4 |
| Friction | How quickly the water slows the character down, per second. | 0 or more | 2 |
| Sink Speed | Sinking speed with no input, m/s. | 0 or more | 0.6 |
| Turn Rate | How fast the body turns toward where it swims, degrees per second (when the states turn the body). | 0 or more | 540 |
| Water Jump Speed | Upward speed of a water jump, m/s. | 0 or more | 6 |