Table of Contents

Class ClimbingRules

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

The climbing movement mode's rules, as pure functions of the climbable, the climber's feet and the tick's controls: the KCC runs them on the server and on the predicting owner alike (and in every replay), so the same inputs give the same climb; the AI walks NPCs along the same geometry; and tests run them with no motor.

public static class ClimbingRules
Inheritance
ClimbingRules
Inherited Members

Remarks

Stateless but for ClimbState. Where the climber is on the climbable is read from its feet each tick (height up the line, offset across it), never stored, so the reconcile only needs which climbable, the phase and the step's ticks. A rope's side is likewise the side its climber is on.

The feet are the character's pivot (the capsule's bottom, as the KCC places it). A climber hangs hang metres out of the line (the body's radius and ClimbHangClearance), so its capsule never touches the climbable's own line.

Fields

ArriveMetres

How near a target counts as there, metres.

public const float ArriveMetres = 0.05

Field Value

float

GrabBelowMetres

How far below a climbable's foot a character can still take hold of it, metres (its feet down a slope).

public const float GrabBelowMetres = 0.5

Field Value

float

IntentDot

How squarely the move input has to point at a climbable to take hold (a cosine).

public const float IntentDot = 0.6

Field Value

float

LostMetres

How far off its climbable a climber may be before its hold is lost (a teleport, a shove), metres.

public const float LostMetres = 3

Field Value

float

MinIntent

The least move input that counts as meaning to go somewhere.

public const float MinIntent = 0.25

Field Value

float

MinRise

The least rise, metres, of a climbable worth climbing.

public const float MinRise = 0.5

Field Value

float

MinUprightness

The least share of its length a climbable rises by (a lean of about 45 degrees at most).

public const float MinUprightness = 0.7

Field Value

float

QueryReach

How far round a character the scene's climbables are looked for, metres: past any reach a rule allows.

public const float QueryReach = 2.5

Field Value

float

SettleMetres

How near the bottom (or the top hold) counts as at it, metres along the line.

public const float SettleMetres = 0.02

Field Value

float

TopGrabBeyond

How far past the landing point a character can be and still step on, metres.

public const float TopGrabBeyond = 0.6

Field Value

float

TopGrabHeight

How far above or below the top a character on the upper floor can be and still step on, metres.

public const float TopGrabHeight = 0.5

Field Value

float

TopGrabSide

How far either side of the climbable's width a character can be and still step on from the top, metres.

public const float TopGrabSide = 0.4

Field Value

float

Methods

Along(in SceneClimbable, Vector3)

How far along the line (from the bottom, metres) a pair of feet are, by their height.

public static float Along(in SceneClimbable c, Vector3 feet)

Parameters

c SceneClimbable
feet Vector3

Returns

float

Attach(ref ClimbState, int, ClimbPhase, float)

Starts a climb on climbable index; a step on from the top is given its ticks.

public static void Attach(ref ClimbState state, int index, ClimbPhase phase, float deltaTime)

Parameters

state ClimbState
index int
phase ClimbPhase
deltaTime float

Axes(in SceneClimbable, ClimbPhase, Vector3, Vector3, out float, out float)

The climb's axes from the move input in the world: pushing into the climbable climbs it, pulling away goes down, and pushing along it shuffles across. The same push that takes hold (TryAttach(in SceneClimbable, Vector3, Vector3, bool, float, out ClimbPhase, out float)) climbs on, and the one that walks off the top onto a ladder carries on down it, whichever way the camera looks; a climber facing its ladder with the camera behind it climbs on forward and comes down on back, as anyone would expect.

public static void Axes(in SceneClimbable c, ClimbPhase phase, Vector3 feet, Vector3 move, out float up, out float side)

Parameters

c SceneClimbable
phase ClimbPhase
feet Vector3
move Vector3
up float
side float

Axis(in SceneClimbable, out float)

The unit direction from the bottom to the top, and the length of the climb.

public static Vector3 Axis(in SceneClimbable c, out float length)

Parameters

c SceneClimbable
length float

Returns

Vector3

CanShuffle(in SceneClimbable)

Whether a climber can shuffle across it: a ladder with a wall behind it, not a rope.

public static bool CanShuffle(in SceneClimbable c)

Parameters

c SceneClimbable

Returns

bool

Exit(in SceneClimbable)

The way off at the top onto the upper floor: its TopExit, else away from where a climber hangs.

public static Vector3 Exit(in SceneClimbable c)

Parameters

c SceneClimbable

Returns

Vector3

Facing(in SceneClimbable, ClimbPhase, Vector3)

The way a climber faces: into the climbable while on it, and along the way off once it is over the top.

public static Vector3 Facing(in SceneClimbable c, ClimbPhase phase, Vector3 feet)

Parameters

c SceneClimbable
phase ClimbPhase
feet Vector3

Returns

Vector3

Flat(Vector3)

public static Vector3 Flat(Vector3 v)

Parameters

v Vector3

Returns

Vector3

HangDirection(in SceneClimbable, Vector3, ClimbPhase)

The horizontal unit direction a climber hangs off the line in: the climbable's Out, or for a free rope the side the feet are on (the pit side of the top, −Exit(in SceneClimbable), when stepping on from it).

public static Vector3 HangDirection(in SceneClimbable c, Vector3 feet, ClimbPhase phase)

Parameters

c SceneClimbable
feet Vector3
phase ClimbPhase

Returns

Vector3

IsValid(in SceneClimbable)

Whether a climbable is one that can be climbed: finite, rising at least MinRise, near upright.

public static bool IsValid(in SceneClimbable c)

Parameters

c SceneClimbable

Returns

bool

KindShare(SceneClimbableKind)

The share of ClimbSpeed a kind is climbed at.

public static float KindShare(SceneClimbableKind kind)

Parameters

kind SceneClimbableKind

Returns

float

Landing(in SceneClimbable)

Where a climber stepping off the top stands on the upper floor.

public static Vector3 Landing(in SceneClimbable c)

Parameters

c SceneClimbable

Returns

Vector3

LinkEnds(in SceneClimbable, out Vector3, out Vector3)

The two ends a NavMesh link joins: the climb's foot on the lower floor and its landing on the upper one.

public static void LinkEnds(in SceneClimbable c, out Vector3 lower, out Vector3 upper)

Parameters

c SceneClimbable
lower Vector3
upper Vector3

PathLength(List<Vector3>)

The length of a run of points, metres.

public static float PathLength(List<Vector3> points)

Parameters

points List<Vector3>

Returns

float

PointAlong(List<Vector3>, float, out int)

The point distance metres along a run of points (clamped to its ends), and the leg it is on.

public static Vector3 PointAlong(List<Vector3> points, float distance, out int leg)

Parameters

points List<Vector3>
distance float
leg int

Returns

Vector3

Release(ref ClimbState, float, float)

Ends a climb, and keeps the character from taking hold again for regrabSeconds.

public static void Release(ref ClimbState state, float regrabSeconds, float deltaTime)

Parameters

state ClimbState
regrabSeconds float
deltaTime float

Right(Vector3)

The horizontal right of a horizontal facing direction (up × it).

public static Vector3 Right(Vector3 horizontal)

Parameters

horizontal Vector3

Returns

Vector3

Step(in SceneClimbable, ref ClimbState, Vector3, in ClimbIntent, float, float, float)

One tick of a climb: the velocity that carries the feet where this tick's controls put them, and the change of phase that comes of it. speedScale is the character's speed attributes (1 = stock).

public static ClimbStep Step(in SceneClimbable c, ref ClimbState state, Vector3 feet, in ClimbIntent intent, float hang, float speedScale, float deltaTime)

Parameters

c SceneClimbable
state ClimbState
feet Vector3
intent ClimbIntent
hang float
speedScale float
deltaTime float

Returns

ClimbStep

TickCooldown(ref ClimbState)

One tick off the wait before a character not climbing may take hold again.

public static void TickCooldown(ref ClimbState state)

Parameters

state ClimbState

TicksFor(float, float)

Whole ticks covering seconds at a tick of deltaTime, 1..255.

public static byte TicksFor(float seconds, float deltaTime)

Parameters

seconds float
deltaTime float

Returns

byte

TopHold(in SceneClimbable)

The highest a climber's feet go while holding on (metres along the line), before it steps off the top.

public static float TopHold(in SceneClimbable c)

Parameters

c SceneClimbable

Returns

float

Toward(Vector3, Vector3, float, float)

The velocity that moves from toward to this tick, at most speed.

public static Vector3 Toward(Vector3 from, Vector3 to, float speed, float deltaTime)

Parameters

from Vector3
to Vector3
speed float
deltaTime float

Returns

Vector3

TraversalPoints(in SceneClimbable, bool, float, Vector3, Vector3, List<Vector3>)

The way an NPC takes along a climbable's NavMesh link, as points for its feet: from where the link starts, to its hold at the foot, up to the top lifted clear of the edge, over to the landing, and on to where the link ends; or the same the other way round going down.

public static void TraversalPoints(in SceneClimbable c, bool upward, float hang, Vector3 start, Vector3 end, List<Vector3> into)

Parameters

c SceneClimbable
upward bool
hang float
start Vector3
end Vector3
into List<Vector3>

TryAttach(in SceneClimbable, Vector3, Vector3, bool, float, out ClimbPhase, out float)

Whether a character can take hold of a climbable now, and how: Holding reached from the floor at its foot or anywhere along it (in the air too) while moving toward it; or SteppingOn from the upper floor, walking off the top's edge onto it. distance ranks the climbables a character could take, nearest first.

public static bool TryAttach(in SceneClimbable c, Vector3 feet, Vector3 move, bool grounded, float hang, out ClimbPhase phase, out float distance)

Parameters

c SceneClimbable
feet Vector3
move Vector3
grounded bool
hang float
phase ClimbPhase
distance float

Returns

bool