Skip to main content

BodyController

A class in Root.Township, Alta.Character.

Moves and turns a player's body to follow the head and hands, using BodyControllerSettings that can be overridden.

Constructors​

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

Fields​

24 private and internal fields
MemberWhat it is
private List<BodyController.BodyControllerSettingsOverride> activeSettingsStack of override settings; the newest still relevant one is used.
private Transform bodyThe body transform being moved and turned.
private Transform bodyTargetTarget whose pitch follows the body's forward bend.
private float finalHeadHeadingHead heading after its impact curve is applied.
private float finalHeadingThe body heading worked out this frame.
private float finalLeftHandHeadingLeft hand heading after its impact curve is applied.
private float finalPitchThe body pitch worked out this frame.
private float finalRightHandHeadingRight hand heading after its impact curve is applied.
private Transform headBacking field for Head.
private float headHeadingHead yaw relative to the body.
private float headHeadingInRoomHead heading used in the weighted heading sum.
private float headRotationMultiplierHow much the head's yaw turns the body, from the settings curve.
private Transform headTargetHead target, moved under the new head when Head changes.
private Transform leftHandThe left hand transform.
private float leftHandHeadingAngleLeft hand angle around the body.
private float leftHandHeadingInRoomLeft hand heading used in the weighted heading sum.
private float leftHandHeadingMultiplierHow much the left hand turns the body, from the settings curve.
private Transform originalHeadThe tracked head, kept while tracking is disabled.
private Transform rightHandThe right hand transform.
private float rightHandHeadingAngleRight hand angle around the body.
private float rightHandHeadingInRoomRight hand heading used in the weighted heading sum.
private float rightHandHeadingMultiplierHow much the right hand turns the body, from the settings curve.
private Transform roomThe play space transform, used to get head height.
private float sideMovementDeclared but not used.

Properties​

MemberWhat it is
Transform BodyTarget { get; }Transform whose pitch is set for the body's forward bend.
Transform BodyTransform { get; }The body transform it moves.
Transform Head { get; set; }The head transform the body follows. Setting it reparents the head target.
BodyControllerSettings Settings { get; }The newest relevant override, or the default from PlayerSettings.

Methods​

MemberWhat it is
void AddOverrideSetting(BodyControllerSettings overrideSettings, Func<bool> relevantCheck)Adds override settings, used while the given check returns true. The newest relevant override wins.
void DisableTracking()Swaps the head for a loose physics box at the same spot, so the body stops following the real head.
void EnableTracking()Puts the real head back and destroys the stand-in.
override void UpdateCharacterComponent()Each frame moves the body towards the head and turns it from head heading, hand positions and head pitch.
1 private and internal method
MemberWhat it is
private float ConstrainAngle(float angle)Wraps an angle to the -180 to 180 range.

Used in​

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