Class ClimbingRules
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
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
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
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
MinIntent
The least move input that counts as meaning to go somewhere.
public const float MinIntent = 0.25
Field Value
MinRise
The least rise, metres, of a climbable worth climbing.
public const float MinRise = 0.5
Field Value
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
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
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
TopGrabBeyond
How far past the landing point a character can be and still step on, metres.
public const float TopGrabBeyond = 0.6
Field Value
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
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
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
cSceneClimbablefeetVector3
Returns
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
stateClimbStateindexintphaseClimbPhasedeltaTimefloat
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
cSceneClimbablephaseClimbPhasefeetVector3moveVector3upfloatsidefloat
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
cSceneClimbablelengthfloat
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
Returns
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
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
cSceneClimbablephaseClimbPhasefeetVector3
Returns
- Vector3
Flat(Vector3)
public static Vector3 Flat(Vector3 v)
Parameters
vVector3
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
cSceneClimbablefeetVector3phaseClimbPhase
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
Returns
KindShare(SceneClimbableKind)
The share of ClimbSpeed a kind is climbed at.
public static float KindShare(SceneClimbableKind kind)
Parameters
kindSceneClimbableKind
Returns
Landing(in SceneClimbable)
Where a climber stepping off the top stands on the upper floor.
public static Vector3 Landing(in SceneClimbable c)
Parameters
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
cSceneClimbablelowerVector3upperVector3
PathLength(List<Vector3>)
The length of a run of points, metres.
public static float PathLength(List<Vector3> points)
Parameters
pointsList<Vector3>
Returns
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
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
stateClimbStateregrabSecondsfloatdeltaTimefloat
Right(Vector3)
The horizontal right of a horizontal facing direction (up × it).
public static Vector3 Right(Vector3 horizontal)
Parameters
horizontalVector3
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
cSceneClimbablestateClimbStatefeetVector3intentClimbIntenthangfloatspeedScalefloatdeltaTimefloat
Returns
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
stateClimbState
TicksFor(float, float)
Whole ticks covering seconds at a tick of deltaTime, 1..255.
public static byte TicksFor(float seconds, float deltaTime)
Parameters
Returns
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
Returns
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
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
cSceneClimbableupwardboolhangfloatstartVector3endVector3intoList<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
cSceneClimbablefeetVector3moveVector3groundedboolhangfloatphaseClimbPhasedistancefloat