Setting up animation controllers in game engines
Animator Controller in Unity – not just transition graph. For VR-character with full locomotion set, interactive reactions, and procedural IK-layers this is complex state machine with multiple layers, Blend Trees, Sub-State Machines, Avatar Masks, and synchronized parameters. Without proper design from start – refactoring Controller with 30+ states becomes nightmare.
Why "simple" graph breaks on scaling
Beginning teams create single Animator with dozens of states and direct transitions. Works for prototype. Adding 10th character with similar, slightly different logic – Controller duplicates and manual edits. Bugs spread.
Correct approach – hierarchy via Animator Override Controller. Base Controller contains structure: layers, parameters, all transitions. For each specific NPC create AnimatorOverrideController, which replaces only Animation Clips, preserving all logic. Allows changing NPC animations without touching transition graph.
Sub-State Machines – mandatory practice for VR-NPC. States divided into logical groups: Locomotion, Combat, Interaction, Dialogue. Transition between groups – simple, within group – complex with conditions. Visually readable and debuggable.
Layered architecture for VR-characters
Typical Animator structure for NPC in VR includes:
Layer 0: Base (Locomotion). Weight 1. Controls lower body half: Blend Tree with parameters Speed (float) and Direction (float). Four speeds – stop, walk, run – minimum. Avatar Mask: only legs and pelvis.
Layer 1: Upper Body. Weight 1, mode Additive or Override. Gestures, dialogue animations, reactions. Avatar Mask: torso and above. Trigger transitions – via SetTrigger("Gesture_Wave"). Exit Time = 0 on transitions from gesture → idle, so don't wait for animation end if interrupted.
Layer 2: IK Overrides. Weight 0–1 managed by code. Here TwoBoneIK Constraint for arm aiming, Look At for gaze. In VR especially important: NPC should look at player, tracking via Animator.SetLookAtPosition() with lookAtWeight around 0.7 (not 1.0 – else neck bends like owl).
Blend Tree vs. State Machine: when to choose what
Blend Tree suits continuous parameters: walk speed, strafe direction, torso lean. State Machine – discrete states: alive/dead, wounded/healthy, standing/crouching.
Mistake: using State Machine for locomotion with condition Speed > 0.5 → Walk. At 0.49 character abruptly switches instead of smooth blending. Blend Tree on same parameter gives correct crossfade.
State Machine transitions for VR: Has Exit Time = false for event reactions (don't wait current animation end), Transition Duration = 0.1–0.2 seconds standard, for combat-reactions = 0.05.
Debugging Controller in VR-project
Animator Debugger in Unity shows current weights and parameters in Play Mode. For VR important to run debugging via Editor with connected headset in Link-mode – Controller behavior in headset can differ due to Fixed Timestep and different framerate. Use Animator.logWarnings = true in dev-builds.
Timeline: setting up base Controller for single character – 1–3 business days; full architecture with Override Controllers and layered structure for project with 5–10 NPC-types – 1–2 weeks. Cost calculated individually.





