Class AnimateHumanoid
- Namespace
- CodeSmile.AnyMotion.AnimateYourself /
- Assembly
- ApiSource.dll
Animates a humanoid character's walk, run and idle entirely from settings, with no animation clips and no Animator Controller. Add this one component to a character that has a Humanoid Avatar; everything else is configured through its Inspector.
[AddComponentMenu("Animate Yourself!/Animate Humanoid")]
[RequireComponent(typeof(WalkGait))]
[RequireComponent(typeof(GaitDriver))]
public sealed class AnimateHumanoid : MonoBehaviour
Expand Details ...
- Inheritance
-
objectObjectComponentBehaviourMonoBehaviourAnimateHumanoid
Remarks
This is the only component of the locomotion system a game or an Inspector should touch. It composes three components on the same GameObject and hides the two it owns:
- RigMetrics measures this character's body once (leg length, hip width, shoulder height). Every setting is a proportion of those measurements rather than a distance in metres, which is what lets one saved set of settings look the same on characters of different sizes and proportions.
-
WalkGaitturns the settings into one pose per frame. It writes nothing to the rig. -
GaitDriverwrites that pose onto the bones after the Animator and after Animation Rigging have run.
The last two are internal and marked UnityEngine.HideFlags.HideInInspector by this
component, so they can neither be added by hand nor edited on their own. Their serialized
data is untouched by that: a character configured before this component existed keeps every
value it had, and adding AnimateHumanoid to it adopts those components rather
than replacing them.
This component may sit on the same object as a character controller. It writes the
character's bones, which are below that object, so it never writes the transform the
controller moves — measured on 2026-08-23, 0.0000 mm of position change over 120 driven steps. The
Window ▸ AnyMotion ▸ Setup Third Person Character Controller menu command wires
a character up this way.
Properties
IsBound
True once the animation system has attached to this character's bones successfully.
public bool IsBound { get; }
Property Value
- bool
IsReady
True once the character has been measured successfully and can be animated. False means RigMetrics has not measured this character yet, or the measurement failed — most often because the Animator's Avatar is not Humanoid, or the character has a non-uniform scale.
public bool IsReady { get; }
Property Value
- bool
LeftHandTarget
Point the left hand reaches for, for example the grip point of a carried object. How far the hand goes towards it is set by Hand Target Weight under IK Targeting, which is 0 by default.
public Transform LeftHandTarget { get; set; }
Property Value
- Transform
LookAtTarget
Object the head, neck and chest turn towards. Null disables looking, in which case the character turns smoothly back to facing forward rather than snapping. Safe to reassign every frame.
public Transform LookAtTarget { get; set; }
Property Value
- Transform
MoveDirection
Direction of travel relative to the direction the character faces, in degrees. 0 is straight ahead, 90 is sideways to the right, -90 sideways to the left, and 180 is walking backwards. Write this alongside MoveSpeed when facing and travel can differ, for example while strafing.
public float MoveDirection { get; set; }
Property Value
- float
MoveSpeed
Current forward speed in metres per second. Write this from a character controller every frame so cadence and stride match the distance actually covered, which is what stops a planted foot from sliding along the ground.
public float MoveSpeed { get; set; }
Property Value
- float
Remarks
Only needed when Derive Speed From Movement is off. With it on (the default) this value is measured from how far the character actually moved and any value written here is replaced.
Parameters
Every animation setting, grouped the same way the Inspector groups them — this character's own walk, before any style is blended on top. Safe to read and change at runtime; changes take effect on the next frame.
public WalkGaitParameters Parameters { get; }
Property Value
Remarks
In the Editor outside Play mode this is the live serialized object, so writing to it from a script marks the scene as changed and persists the value.
A style blend treats these values as the base it blends away from, so a write here survives being styled rather than being overwritten by the blend — which is why this is the authored set and not the resolved one. Read ResolvedParameters for the values actually in effect this frame.
Phase
Position within the current gait cycle, from 0 to 1. One cycle is two steps. Writing it moves the character to that point in the cycle immediately.
public float Phase { get; set; }
Property Value
- float
Remarks
Set this once per character when spawning a crowd. Every character starts at phase 0, so characters spawned in the same frame with the same settings plant their feet in step with each other. One line in a spawner is the whole fix:
humanoid.Phase = UnityEngine.Random.value;
It is per character rather than a setting inside Parameters deliberately: a saved preset is shared by every character using it, so a starting phase stored there would give all of them the same one, which is not a crowd out of step. The random seed under Irregularity does not cover this either — it varies the noise added on top of the cycle, not where in the cycle the character is.
Values outside 0..1 wrap rather than clamp, so a phase of 1.25 is the same as 0.25 and a negative one counts backwards from 1.
Writing this mid-walk is allowed and jumps the whole cycle, both legs included, to the given position — it is not a smooth transition, and a planted foot moves. Assign it before the character starts moving.
Pose
The pose produced for the current frame: foot and hand targets, hip position, joint angles.
public GaitPose Pose { get; }
Property Value
ResolvedParameters
The settings actually in effect this frame, after any style blend. Read-only in practice: writes to it are overwritten on the next frame — change Parameters instead.
public WalkGaitParameters ResolvedParameters { get; }
Property Value
Remarks
With no style set assigned this is the same object as Parameters, so
ReferenceEquals(Parameters, ResolvedParameters) answers "is this character styled".
RightHandTarget
Point the right hand reaches for. Works exactly like LeftHandTarget.
public Transform RightHandTarget { get; set; }
Property Value
- Transform
Style
How much of each named style this character is using, when a Gait Style Set is assigned to it. Blending a style in changes the whole walk at once, so a game can drive movement from something it already tracks — health, fatigue, mood, a faction — instead of changing individual settings under Parameters.
public HumanoidStyle Style { get; }
Property Value
Remarks
Always usable. With no style set assigned it reports no styles and every write through it does nothing, so game code shared by styled and unstyled characters needs no test of its own.
Which styles exist is authored in the Gait Style Set; this is only how much of each one this character is using. Two characters sharing one set can therefore carry different mixes.
Weight
How strongly the procedural animation is applied, from 0 (the character stays in its unanimated rest pose) to 1 (full animation). Values in between fade the animation in or out.
public float Weight { get; set; }
Property Value
- float
Methods
ApplyNow()
Writes the current pose onto the bones immediately, instead of waiting for the end of the frame. Only needed for tooling that inspects a single instant; ordinary game code never calls this.
public void ApplyNow()
Remarks
Does nothing once this component or the driver it owns has been destroyed.
ApplyParameters(WalkGaitParameters)
Replaces every setting at once, for example with one of the named presets on WalkGaitParameters. Passing null restores the defaults.
public void ApplyParameters(WalkGaitParameters parameters)
Parameters
| Type | Name | Description |
|---|---|---|
parameters |
Remarks
Does nothing, and writes nothing to the console, once this component or the gait it owns has been destroyed.
ResetPhase()
Restarts the gait cycle from the beginning, with both feet back at their starting position.
public void ResetPhase()
Remarks
Does nothing once this component or the gait it owns has been destroyed.
ResetPose()
Puts the character back into its unanimated rest pose, re-reads that pose from the mesh, re-attaches to the bones and restarts the cycle. Use it if the character is left in an odd pose, for example after a script recompile interrupted the animation.
public void ResetPose()
Remarks
Does nothing once this component or the driver it owns has been destroyed.
Events
FootMissedGround
Raised when a foot's downward ground probe found nothing to stand on, for example because the foot swung out over a ledge. The argument is true for the left foot and false for the right. Use it to react in game code; the animation itself already handles the case by keeping the foot within a normal stride instead of stretching the leg towards nothing.
public event Action<bool> FootMissedGround
Event Type
- Action<bool>
Remarks
Provisional: the payload of every runtime event in this asset is being settled as one public contract (R13, public event surface) before release, so its shape may still change.