Table of Contents

Class FootfallTracker

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Finds one body's footfalls, frame by frame. Owned by its CharacterBody; pure state and arithmetic, so its rules can be tested without a model.

public sealed class FootfallTracker
Inheritance
FootfallTracker
Inherited Members

Fields

LiftMetres

A foot this far above the ground (metres, sole to ground) is in the air.

public const float LiftMetres = 0.06

Field Value

float

MinLandSpeed

A fall slower than this (m/s, downward) lands as a step, not a landing.

public const float MinLandSpeed = 2.5

Field Value

float

MinStepSeconds

The least time between two footfalls of the same foot, seconds: a foot jittering at the plant line is one step.

public const float MinStepSeconds = 0.18

Field Value

float

MinStepSpeed

Below this ground speed (m/s) a foot moving is a shuffle, not a step.

public const float MinStepSpeed = 0.3

Field Value

float

PlantMetres

A lifted foot back within this of the ground has come down.

public const float PlantMetres = 0.025

Field Value

float

StrokeMetres

Metres swum at the surface for each stroke.

public const float StrokeMetres = 1.1

Field Value

float

Properties

NextFoot

The foot Rung(bool, float, float) last used.

public int NextFoot { get; }

Property Value

int

Methods

FootDown(int, float, float, float)

One foot seen this frame, gap metres above the ground under it: whether it has just come down (lifted, now within PlantMetres, moving, and not within MinStepSeconds of its last). A foot that was never seen lifted does not step, so a body that stands still is silent.

public bool FootDown(int foot, float gap, float speed, float now)

Parameters

foot int
gap float
speed float
now float

Returns

bool

Landed(bool, bool, float, out float)

The air, frame by frame: how fast the body comes down while it is off the ground, and on the frame it is back whether that was a landing (at least MinLandSpeed; its speed out).

public bool Landed(bool airborne, bool grounded, float verticalSpeed, out float speed)

Parameters

airborne bool
grounded bool
verticalSpeed float
speed float

Returns

bool

Reset()

Forgets every foot's state: a teleport, a respawn, a new model.

public void Reset()

Rung(bool, float, float)

Climbing moved metres up or down a ladder: whether a hand or foot takes the next rung.

public bool Rung(bool climbing, float moved, float rungMetres)

Parameters

climbing bool
moved float
rungMetres float

Returns

bool

StepMetres(float, float)

The length of one step (half a stride), metres, at a ground speed, for a body 1.8 m tall: about 0.75 m at a walk (1.4 m/s, 1.9 steps a second), 1.4 m at a run (4 m/s), 1.9 m at a sprint (6.5 m/s). A taller body steps further in proportion.

public static float StepMetres(float speed, float height)

Parameters

speed float
height float

Returns

float

Stride(float, float, float)

A body whose feet cannot be seen, gone moved metres along the ground: which foot steps now, or -1 for none yet.

public int Stride(float moved, float speed, float height)

Parameters

moved float
speed float
height float

Returns

int

Swim(bool, float, float, float, out float)

The water, frame by frame: on the frame the body goes in, whether it went in falling (a plunge); while it swims at the surface, whether a stroke breaks the water now. The fall speed is the one Landed(bool, bool, float, out float) kept.

public FootfallKind? Swim(bool swimming, float atSurface, float moved, float verticalSpeed, out float speed)

Parameters

swimming bool
atSurface float
moved float
verticalSpeed float
speed float

Returns

FootfallKind?