Skip to main content

MovementBendController

A class in Root.Township, the global namespace.

Client-side visual: tilts a player's skirt bone as their head moves, so the body leans with movement. Removed on headless servers; for the local player it follows the body bending setting.

Constructors​

MemberWhat it is
MovementBendController()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

11 private and internal fields
MemberWhat it is
private Quaternion baseSkirtRotationLocal rotation of the bone with no bend.
private BodyController bodyControllerBody controller giving the head position and settings.
private bool btnReadInspector button flag labelled Read Rotation.
private CharacterDummyPointer dummyCharacter dummy that owns the bone.
private Vector3 lastPositionLagging head position on the ground plane.
private static Logger loggerClass logger; unused in this build.
private float maxDistanceSquaredIf the head jumps further than this (squared), the bend resets, as after a teleport.
private Quaternion movementBendCurrent bend rotation.
private Vector3 originalUpReference direction used to orient the bend axis.
private Transform skirtMovementTargetBone transform being rotated.
private BoneIdentifier skirtMovementTargetBoneWhich bone to rotate.

Methods​

7 private and internal methods
MemberWhat it is
private void CalculateMovementBend(Vector3 headPosition, BodyControllerSettings settings)Works out a bend from how far the head has moved from a lagging point and blends the bone rotation toward it.
private void CheckForEnabledInSettings(Settings settings)Enables the component based on the local player's body bending setting.
private void OnDestroy()Unhooks the settings event.
private void OnDisable()Resets the bend and the lagging position.
private void OnDrawGizmosSelected()Draws the lagging point and a line to the head.
private void Start()Finds the target bone; destroys itself on headless servers.
private void Update()Updates the bend each frame, or disables itself if the player is being destroyed.