Animation¶
Control Unity's animation system from the Inspector - trigger states, play clips, and drive parameters without code.
Jungle.Animation covers all three of Unity's animation systems: Animator Controllers, legacy Animation clips, and Timeline (PlayableDirector). You can fire triggers, set parameters, play states, and run cutscenes by simply choosing the right action from a dropdown - no scripting required. When you need multi-frame behaviors (wait for an animation to finish, smoothly drive a blend parameter), dedicated processes handle the timing for you.
Dependencies¶
| Package | Why |
|---|---|
| Jungle.Core | Base interfaces (IProcess, ICommand, IValue<T>), attributes |
| Jungle.Spatial | Transform-related utilities |
| Jungle.Objects | IGameObject target resolution |
| Jungle.Math | SmartFloat, numeric value types |
Assembly: Jungle.Animation - namespace Jungle.Animation (effects/processes) and Jungle.Animation.GameDev (values).
Animator Command¶
The Animator Command is the primary way to interact with an Animator from a command sequence. Instead of writing a separate script for each parameter change, you configure a composable list of actions that all execute against a single Animator target in one frame. Add the actions you need, reorder them in the Inspector, and you are done.
Under the hood, this is the AnimatorCommand class, selectable through the standard class picker:
[SerializeReference] [JungleClassSelection]
private ICommand animatorCommand;
// Select "Animator Command" from the class picker
Animator Actions¶
Each action performs one operation on the resolved Animator (they implement IAnimatorAction internally):
| Action | Description | Key Fields |
|---|---|---|
| Set Trigger | Fires a trigger parameter (one-shot signal) | triggerName |
| Set Bool | Sets a boolean parameter | parameterName, value |
| Set Float | Sets a float parameter (supports SmartFloat for dynamic sources) |
parameterName, value |
| Set Int | Sets an integer parameter | parameterName, value |
| Play State | Plays a specific animator state by name | stateName, layerIndex, startNormalizedTime |
Actions are stored as a [SerializeReference] list, so you can add, remove, and reorder them in the Inspector.
Example: Trigger an attack animation and set speed¶
// In your MonoBehaviour or process configuration:
[SerializeReference] [JungleClassSelection]
private ICommand onAttack;
// In the Inspector, select "Animator Command", then add:
// 1. Set Float -> parameterName: "Speed", value: 1.5
// 2. Set Trigger -> triggerName: "Attack"
At runtime, calling onAttack.Execute() sets the speed parameter and fires the attack trigger in a single frame.
Processes¶
Jungle.Animation provides three IProcess implementations for operations that span multiple frames. Each follows the standard process lifecycle.
AnimatorStateProcess¶
Plays a specific Animator state and completes when the animation finishes.
| Field | Type | Description |
|---|---|---|
targetAnimatorObject |
IGameObject |
The GameObject with the Animator |
stateName |
IStringValue |
State name in the Animator Controller |
layerIndex |
IIntValue |
Animator layer (default 0) |
startNormalizedTime |
float |
Where to start playback (0 = beginning) |
completeOnAnimationEnd |
bool |
If true, completes at normalizedTime >= 1. If false (looping clips), completes only when a transition out begins. |
[SerializeReference] [JungleClassSelection]
private IProcess introAnimation;
// Select "Animator State Process"
// Set stateName to "Intro", completeOnAnimationEnd to true
Tip
For looping clips, set completeOnAnimationEnd to false. The process will complete when the Animator transitions out of the state, letting you control timing via Animator Controller transitions.
AnimationPlayProcess¶
Plays a legacy Animation clip and completes when it finishes.
| Field | Type | Description |
|---|---|---|
targetObject |
IGameObject |
The GameObject with the Animation component |
clip |
AnimationClip |
The legacy clip to play |
restartFromBeginning |
bool |
Rewind before playing (default true) |
Note
This process targets the legacy UnityEngine.Animation component, not the Animator. Use it for simple one-off animations that do not need a full Animator Controller.
PlayableDirectorProcess¶
Plays a PlayableDirector (Timeline) and completes when playback finishes.
| Field | Type | Description |
|---|---|---|
targetDirectorObject |
IGameObject |
The GameObject with the PlayableDirector |
restartFromBeginning |
bool |
Reset to time 0 before playing (default true) |
Completion is detected via the PlayableDirector.stopped event, so it works with any Timeline duration.
[SerializeReference] [JungleClassSelection]
private IProcess cutscene;
// Select "Playable Director Process"
// Point targetDirectorObject at the Timeline GameObject
Commands¶
PlayableDirectorStartCommand¶
A fire-and-forget command that starts a PlayableDirector without waiting for completion. Use this when you want to kick off a Timeline but do not need to block a sequence on it.
| Field | Type | Description |
|---|---|---|
targetDirectorObject |
IGameObject |
The GameObject with the PlayableDirector |
restartFromBeginning |
bool |
Reset to time 0 before playing (default true) |
This is a TargetedCommand, so it supports OverrideTarget for dynamic targeting at runtime.
Value Providers¶
Jungle.Animation adds AnimationClip to the value provider system.
IAnimationClipValue / ISettableAnimationClipValue¶
Interfaces for providing AnimationClip references. Use these as field types when a component needs a clip that could come from different sources.
Concrete Providers¶
| Provider | Description | When to Use |
|---|---|---|
| AnimationClipValue | Stores a clip directly on the owning component | Simple, single-clip reference |
| AnimationClipValueFromAsset | Reads from an AnimationClipValueAsset ScriptableObject |
Shared clip reference across multiple objects |
| AnimationClipListValueFromAsset | Reads a list of clips from an AnimationClipListValueAsset |
Random or indexed clip selection |
ScriptableObject Assets¶
| Asset | Menu Path | Description |
|---|---|---|
| AnimationClipValueAsset | Jungle/Animation/AnimationClip Value |
Stores a single AnimationClip |
| AnimationClipListValueAsset | Jungle/Animation/AnimationClip List Value |
Stores a list of AnimationClip references |
// Use in a component field:
[SerializeReference] [JungleClassSelection]
private IAnimationClipValue clip;
// Inspector offers: "Animation Clip Value" (local) or "Animation Clip Value From Asset" (shared)
Animator Float Pipeline¶
Info
The AnimatorFloatPipeline originated in Jungle.Animation and may be located in a separate assembly in some configurations.
A pipeline process that drives an Animator float parameter over time. It reads from a configurable float target, applies modifiers, and writes the result to the Animator each frame.
| Field | Type | Description |
|---|---|---|
targetAnimatorObject |
IGameObject |
The GameObject with the Animator |
parameterName |
IStringValue |
The float parameter name to drive |
Use this to smoothly transition blend tree weights, speed multipliers, or any continuous Animator parameter through the pipeline system.
[SerializeReference] [JungleClassSelection]
private IProcess blendTransition;
// Select "Animator Float Pipeline"
// Set parameterName to "Blend", configure a LerpFloatTarget for smooth transition
Putting It Together¶
A typical setup for a character that plays an intro animation, then idles:
public class CharacterIntro : MonoBehaviour
{
[SerializeReference] [JungleClassSelection]
private IProcess introState;
// -> Animator State Process (stateName: "Intro", completeOnAnimationEnd: true)
[SerializeReference] [JungleClassSelection]
private ICommand setIdle;
// -> Animator Command with actions:
// Set Bool -> parameterName: "IsIdle", value: true
private void Start()
{
introState.Begin(onComplete: () =>
{
setIdle.Execute();
});
}
}
All animation behavior is configured in the Inspector. Swapping the intro from an Animator state to a Timeline is a single dropdown change from "Animator State Process" to "Playable Director Process" - no code modification required.