Skip to main content

SmoothLocomotionSettings

A class in Root.Township, the global namespace.

Global tuning for the player's smooth (stick) locomotion: speeds, step and slope handling, falling, fall damage and safety recovery. Get it with GlobalSettings<SmoothLocomotionSettings>.Instance; read by SmoothLocomotion.

Constructors​

MemberWhat it is
SmoothLocomotionSettings()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

42 private and internal fields
MemberWhat it is
private float clampedSpeedTop speed for stick movement; faster input movement is clamped to it.
private float combatSpeedMultiplierSpeed multiplier applied in combat.
private float dangerDamageBacking field for DangerDamage.
private LayerMask dangerMaskLayers counted as dangerous; a safe spot can't be within 1 m of them.
private float decelerateLerpHow fast speed falls off when you let go.
private PlayerMode disableRotatorOnActiveHandForBacking field for DisableRotatorOnActiveHandFor. Defaults to every mode.
private float distanceToCheckForInfiniteFallHow far down to look for ground; if none is found the player is moved to safety.
private float extraHeightAdded to the head height when working out the body height.
private AnimationCurve fallCrippleDamageOverDistanceCurve from fall height to cripple damage.
private AnimationCurve fallDamageOverDistanceCurve from fall height to fall damage. Its last key sets maxFallDistance.
private SoundEffectSet fallDamageSoundSound played on landing.
private AnimationCurve fallEffectsScaleOverDistanceCurve from fall height to the size of the landing effect.
private AnimationCurve fallingControlOverTimeCurve from time falling to how much steering you keep.
private float gravityMultiplierScale on gravity for the smooth locomotion body.
private float hasMovedSensitivitySquaredSquared distance the local player's feet must move to count as having moved.
private AnimationCurve heightAdjustmentLerpCurve used by LerpHeight to ease the body height toward its target.
private HungerStat hungerStatDefinitionHunger stat whose level decides if CanRun allows running.
private float hungrySoundCooldownSeconds between plays of the too-hungry-to-run sound.
private AnimationCurve inputCurveCurve from stick amount to speed.
private float leanLimitHow far the body can lean away from the head before it is pulled back.
private float maxAngleBeforeSlopeDotSlope steepness (as a normal y value) past which the player slides.
private float maxFallDistanceFall height at the end of the damage curve. Set by OnValidate.
private int maxLevelToRunHunger level at or below which running needs some fullness.
private float minDistanceForEffectBacking field for MinDistanceForEffect.
private float minimumHeightLowest the body height can go.
private float minimumVelocityLowest move speed used once moving. Also read by AI regain control.
private float normalStepHeightUsual step height, and a floor on the body height.
private TransformScaledEvent onHitGroundEffectScaledEffect played on landing, scaled by the fall.
private float pressAccelerateLerpHow fast you speed up while running (stick pressed).
private float pressedSpeedRunning speed with the stick pressed.
private float recoverFromSafetyRepositionBlackFadeDurationSeconds the screen stays black after a safety move before fading back.
private float recoverFromSafetyRepositionDurationTotal seconds of the recover state after being moved to safety.
private float recoveryFadeBlacknessBlackness for the recovery fade. Nothing reads it in this build.
private LayerMask safetyMaskLayers that count as safe ground to be moved back to.
private float slipValueIncreaseDurationSeconds for sliding on a steep slope to build to full.
private float slopeHelperDistanceExtra distance for ground checks that keep you stuck to slopes.
private float slopeMultiplierHow strongly a steep slope pushes you down it.
private LayerMask standableMaskLayers you can stand on.
private float teleportFallTimerThe teleporter only switches on while you have been falling for less than this many seconds.
private float touchAccelerateLerpHow fast you speed up while walking.
private float touchedSpeedWalking speed.
private SoundEffectSet tryingToRunSoundSound played when you try to run while too hungry.

Properties​

MemberWhat it is
float ClampedSpeed { get; }Top horizontal speed movement is clamped to.
float CombatSpeedMultiplier { get; }Speed multiplier applied while in combat.
float DangerDamage { get; }Damage value for danger layers. Nothing reads it in this build.
LayerMask DangerMask { get; }Layers counted as dangerous; a safe recovery point can't be within 1 m of them.
float DecelerateLerp { get; }How fast movement speed falls off when input stops.
PlayerMode DisableRotatorOnActiveHandFor { get; }Player modes for which turning is meant to be disabled on the active hand. Nothing reads it in this build.
float DistanceToCheckForInfiniteFall { get; }How far down to look for ground; with none in range the player is moved back to safety.
float ExtraHeight { get; }Added to the head height when working out the character height.
AnimationCurve FallCrippleDamageOverDistance { get; }Curve from fall height to the crippling part of fall damage.
AnimationCurve FallDamageOverDistance { get; }Curve from fall height to fall damage. Its last key sets MaxFallDistance.
SoundEffectSet FallDamageSound { get; }Sound played on fall damage.
AnimationCurve FallEffectsScaleOverDistance { get; }Curve from fall height to the scale of the landing effect.
AnimationCurve FallingControlOverTime { get; }Curve from time spent falling to how much input control is left.
float GravityMultiplier { get; }Gravity multiplier for the player.
float HasMovedSensitivitySquared { get; }Squared distance the local player's feet must move before it counts as having moved.
float HungrySoundCooldown { get; }Minimum seconds between "too hungry to run" sounds.
AnimationCurve InputCurve { get; }Curve applied to stick input strength.
float LeanLimit { get; }How far the head can lean from the body before the character is repositioned.
float MaxAngleBeforeSlopeDot { get; }Ground normal Y below which the ground counts as a slope you slide on.
float MaxFallDistance { get; }Largest fall distance that is synced; copied from the fall damage curve's last key.
float MinDistanceForEffect { get; }Minimum fall distance for the landing effect. Nothing reads it in this build.
float MinimumHeight { get; }Lowest the character height can be.
float MinimumVelocity { get; }Lowest move speed while input is applied. Creatures regaining control also use it.
float NormalStepHeight { get; }Step height the character controller uses.
TransformScaledEvent OnHitGroundEffectScaled { get; }Effect event raised on landing, scaled by fall height.
float PressAccelerateLerp { get; }How fast speed builds up when the stick is pressed (running).
float PressedSpeed { get; }Move speed when the stick is pressed in.
float RecoverFromSafetyRepositionBlackFadeDuration { get; }Fade to black time when the player is moved back to safety.
float RecoverFromSafetyRepositionDuration { get; }How long the move back to safety takes.
float RecoveryFadeBlackness { get; }How dark the screen goes during safety recovery.
LayerMask SafetyMask { get; }Layers a player can be put back onto when moved to safety.
float SlipValueIncreaseDuration { get; }Seconds for sliding on a steep slope to build up to full.
float SlopeHelperDistance { get; }Extra distance below the feet checked for ground, to stick to slopes.
float SlopeMultiplier { get; }Strength of sliding down a steep slope.
LayerMask StandableMask { get; }Layers the player can stand on.
float TeleportFallTimer { get; }Seconds of falling after which the teleporters are turned off.
float TouchAccelerateLerp { get; }How fast speed builds up when the stick is only touched (walking).
float TouchedSpeed { get; }Move speed when the stick is only touched.
SoundEffectSet TryingToRunHungrySound { get; }Sound played when the player tries to run while too hungry.
float WalkingSpeedMultiplier { get; set; }Runtime multiplier on walking speed. Settable.

Methods​

MemberWhat it is
bool CanRun(Stat hungerStat, Stat fullnessStat)True unless the hunger stat is enabled and at level 2 or lower; then running needs some fullness left.
float LerpHeight(float currenty, float targetY)Smooths a height towards a target using the height adjustment curve.
1 private and internal method
MemberWhat it is
private void OnValidate()Editor: sets maxFallDistance to the last key of the fall damage curve.

Used in​

Members of other types that take, return or hold a SmoothLocomotionSettings: