Skip to main content

ElbowController

A class in Root.Township, Alta.Character.

Character rig component that places the elbow IK hint by matching the hand's pose against a set of recorded elbow data points and averaging the best matches.

Constructors​

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

Fields​

13 private and internal fields
MemberWhat it is
private Vector3 averagePointLast computed elbow hint position in world space.
private GameObject averagePointVisualDebug sphere showing averagePoint.
private List<ElbowDataPointScore> bestMatchesSorted list of the best scoring data points this update.
private Transform bodyBacking field for Body.
private float[] dataPointDistanceSquaredScratch array of squared distances from the hand to each data point.
private List<IElbowGuideDataPoint> dataPointsData points for this hand, mirrored where needed.
private List<GameObject> dataPointVisualsDebug spheres for the best matches.
private Transform elbowBacking field for Elbow.
private Transform elbowTargetBacking field for ElbowTarget.
private HandIndex handIndexBacking field for HandIndex.
private Transform handTargetBacking field for HandTarget.
private int numberOfBestMatchedToAverageBacking field for NumberOfBestMatchedToAverage.
private Transform shoulderBacking field for Shoulder.

Properties​

MemberWhat it is
Transform Body { get; set; }Body transform that hand positions and data points are measured in.
Transform Elbow { get; set; }The elbow (forearm) bone.
ElbowDataPointSet ElbowDataPoints { get; set; }The shared ElbowDataPointSet on PlayerSettings. Setting it only works if none is set yet.
Transform ElbowTarget { get; set; }The elbow hint transform moved towards the best match each fixed update.
HandIndex HandIndex { get; set; }Which arm this is; data points for the other hand are mirrored.
Transform HandTarget { get; set; }Hand IK target used to pick matching data points.
int NumberOfBestMatchedToAverage { get; set; }How many of the best data points are averaged. Read from settings in Awake.
Transform Shoulder { get; set; }The shoulder bone.
1 private and internal property
MemberWhat it is
private ElbowControllerSettings Settings { get; }Shortcut to PlayerSettings.ElbowControllerSettings.

Methods​

MemberWhat it is
override void FixedUpdateCharacterComponent()Moves the elbow target towards the best hint position at a speed from the settings curve.
5 private and internal methods
MemberWhat it is
private void Awake()Creates debug visuals if enabled, reads the match count from settings and loads the data points.
private void CreateDataPointVisuals()Debug: spawns small spheres for the best matches (red) and their average (green).
private Vector3 FindBestElbowHintPosition()Scores data points by hand position and rotation and returns the (optionally weighted) average elbow hint of the best ones.
private void PopulateDataPointLists()Loads the data points, mirroring those recorded for the other hand.
private void UpdateDataPointVisuals()Debug: moves the match spheres to the current best points, rebuilding them if the count changed.

Used in​

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