Skip to main content

ShoulderTwistController

A class in Root.Township, Alta.Character.

Character rig component that slowly twists the shoulder around the shoulder-to-elbow axis to follow the hand, within a rotation limit.

Constructors​

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

Fields​

9 private and internal fields
MemberWhat it is
private Transform bodyBacking field for Body.
private Transform elbowBacking field for Elbow.
private Transform handBacking field for Hand.
private Vector3 handVectorLast elbow-to-hand vector in shoulder space.
private Vector3 rotationAxisShoulder-to-elbow axis the twist is applied around.
private RotationLimit rotationLimitBacking field for RotationLimit.
private Transform shoulderBacking field for Shoulder.
private float speedTwist speed in degrees per second (default 5).
private float startAngleForearm angle at Start, which the twist direction is measured from.

Properties​

MemberWhat it is
Transform Body { set; }Body transform (set only).
Transform Elbow { set; }Elbow bone (set only).
Transform Hand { set; }Hand bone (set only).
RotationLimit RotationLimit { set; }Rotation limit applied to the shoulder after twisting (set only).
Transform Shoulder { get; set; }The shoulder bone this rotates.

Methods​

MemberWhat it is
override void FixedUpdateCharacterComponent()Rotates the shoulder towards the hand's angle at speed, applies the limit and keeps the elbow's rotation unchanged.
3 private and internal methods
MemberWhat it is
private float GetHandVectorAngle()Angle of the forearm vector (elbow to hand) in the shoulder's space.
private void OnDrawGizmos()Gizmo hook; draws nothing in this build.
private void Start()Records the starting forearm angle.

Used in​

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