Skip to main content

CharacterRigPoser

A class in Root.Township, the global namespace.

Copies a player character's pose onto a dummy rig, bone by bone from the root outwards, over a set time. Used by EquipmentCustomizationRoom.

Constructors​

MemberWhat it is
CharacterRigPoser(Transform dummyRootBone, Transform dummyBodyTransform, Transform characterRigRootBone, Transform characterBodyTransform, Func<Transform, bool> dummyBonesFilter, Func<Transform, Transform> boneMapFromPlayerToDummy, float minTimeBetweenPoses = 2)Creates a CharacterRigPoser from dummyRootBone, dummyBodyTransform, characterRigRootBone, characterBodyTransform, dummyBonesFilter, boneMapFromPlayerToDummy and minTimeBetweenPoses.

Fields​

11 private and internal fields
MemberWhat it is
private Func<Transform, Transform> boneMapFromPlayerToDummyFinds the player bone that matches a dummy bone (despite the name, it maps dummy to player).
private List<List<Transform>> boneStagesDummy bones grouped by depth, posed one group at a time.
private Transform characterBodyTransformThe player character's body transform.
private Transform characterRigRootBoneThe player character's root bone.
private Transform dummyBodyTransformThe dummy's body transform.
private Transform dummyRootBoneThe dummy's root bone.
private Func<Transform, bool> isDummyBoneValidFilterFilter that decides which dummy bones are posed.
private float lastPoseTimeTime the last pose copy started.
private float minTimeBetweenPosesMinimum seconds between pose copies. Defaults to 2.
private int numberOfStagesNumber of bone depth stages.
private AltaCoroutine posingAnimationThe running pose coroutine, stopped if a new pose starts.

Methods​

MemberWhat it is
bool AttemptToCopyPlayerCharactersPose(float animationDuration, float animationStageOverlap)Starts copying the pose. Returns false if the last pose was less than minTimeBetweenPoses ago.
9 private and internal methods
MemberWhat it is
private IEnumerator AnimateBodyRoot(float animationDuration) (iterator)Moves the dummy body to the character body's height and tilt (ignoring yaw and horizontal position).
private IEnumerator AnimateBoneLocalPosition(Transform bone, Vector3 targetLocalPosition, float duration) (iterator)Coroutine that moves a bone's local position to a target over a duration.
private IEnumerator AnimateBoneLocalRotation(Transform bone, Quaternion targetLocalRotation, float duration) (iterator)Coroutine that rotates a bone's local rotation to a target over a duration, or at once if the duration is 0.
private IEnumerator AnimateDummyPose(float totalDuration, float stageAnimationOverlap) (iterator)Coroutine that poses the body root, then each bone stage in turn with some overlap.
private void CopyPosition(Transform targetTransform, Transform originalTransform, float animationDuration)Starts moving a transform to another's local height, with X and Z zeroed.
private void CopyRotation(Transform targetTransform, Transform originalTransform, float animationDuration)Starts rotating a transform to another's local rotation, with yaw zeroed.
private int GetMaxBoneDepth(Transform bone, int maxBoneDepth)Returns the deepest scene hierarchy depth under a bone.
private void PrepareBonesStages()Groups the dummy's bones by depth into stages, skipping bones the filter rejects.
private void StartBoneAnimation(Transform currentBone, float animationDuration)Starts rotating a dummy bone to match its player bone. Logs a warning if no match is found.

Used in​

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