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). Each system has a dedicated command that resolves a target component and runs a composable list of operations against it. Operations can be instant (set a parameter, fire a trigger) or timed (play a state and wait for it to finish). When you need multi-frame behaviors, timed operations self-tick and keep the parent command alive until they complete - no separate process wiring required.
Dependencies¶
| Package | Why |
|---|---|
| Jungle.Core | Base interfaces (IProcess, IOperation, IValue<T>), attributes |
| Jungle.Spatial | Transform-related utilities |
| Jungle.Objects | SmartGameObject target resolution |
| Jungle.Math | SmartFloat, numeric value types |
Assembly: Jungle.Animation - namespace Jungle.Animation (effects/operations) 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 operations that all execute against a single Animator target in parallel. Add the operations you need, reorder them in the Inspector, and you are done.
Under the hood, AnimatorCommand extends TargetedCommand<Animator, IAnimatorOperation>. Each operation receives the resolved Animator and a completion callback. Instant operations call back immediately; timed operations (like Animator State) self-tick and call back when finished. The command completes once every operation has reported completion.
[SerializeReference] [JungleClassSelection]
private IProcess animatorCommand;
// Select "Animator Command" from the class picker
- Target: the Animator every operation acts on.
- Operations: each + adds one step, and they all start together.
Animator Operations¶
Each operation performs one action on the resolved Animator (they implement IAnimatorOperation internally):
| Operation | 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 |
| Animator State | Plays a state and completes when the animation finishes | stateName, layerIndex, startNormalizedTime, completeOnAnimationEnd |
Instant operations (Set Trigger, Set Bool, Set Float, Set Int, Play State) complete in the same frame. The Animator State operation is a timed operation - it self-ticks each frame, checking for animation completion, and keeps the parent command alive until the state finishes.
Operations 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 IProcess 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.Begin(...) sets the speed parameter and fires the attack trigger in a single frame.
Animation Command¶
The Animation Command follows the same TargetedCommand<TTarget, TOperation> pattern for the legacy UnityEngine.Animation component. It extends TargetedCommand<Animation, IAnimationOperation> and runs a list of IAnimationOperation operations against a single Animation target.
| Operation | Description | Key Fields |
|---|---|---|
| Play Clip | Plays a legacy Animation clip and completes when it finishes | clip, restartFromBeginning |
The Play Clip operation is a timed operation - it self-ticks each frame, checking whether the clip is still playing, and keeps the parent command alive until playback completes.
[SerializeReference] [JungleClassSelection]
private IProcess legacyAnimation;
// Select "Animation Command", then add a "Play Clip" operation
Note
This command targets the legacy UnityEngine.Animation component, not the Animator. Use it for simple one-off animations that do not need a full Animator Controller.
Playable Director Command¶
The Playable Director Command extends TargetedCommand<PlayableDirector, IPlayableDirectorOperation> and runs a list of operations against a single PlayableDirector (Timeline) target.
| Operation | Description | Key Fields |
|---|---|---|
| Start Director | Starts the PlayableDirector without waiting for completion (fire-and-forget) | restartFromBeginning |
| Play Director | Plays the Director and completes when playback finishes | restartFromBeginning |
Start Director is an instant operation - it kicks off the Timeline and completes immediately. Play Director is a timed operation that listens for the PlayableDirector.stopped event and keeps the parent command alive until playback finishes.
[SerializeReference] [JungleClassSelection]
private IProcess cutscene;
// Select "Playable Director Command", then add a "Play Director" operation
Tip
Use Start Director when you want to kick off a Timeline but do not need to block a sequence on it. Use Play Director when subsequent operations should wait for the Timeline to finish.
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 |
ScriptableObject Assets¶
| Asset | Menu Path | Description |
|---|---|---|
// 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
AnimatorFloatPipelineOperation ships in Anteloope's Animation package; it is not part of Jungle Core.
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.
It is an IAnimatorOperation, so it goes inside an AnimatorCommand, which resolves the Animator through its own SmartAnimator field. The operation itself only names the parameter.
| Field | Type | Description |
|---|---|---|
parameterName |
string |
The float parameter to drive (default Blend) |
Use this to smoothly transition blend tree weights, speed multipliers, or any continuous Animator parameter through the pipeline system.
// On an AnimatorCommand's operations list, pick "Set Float Over Time",
// set parameterName to "Blend" and give it a destination to drive toward.
- Destination: the value the parameter moves toward each frame.
- Parameter Name: the Animator float to drive.
- Modifiers: optional smoothing, clamping or noise applied on the way.
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 Command with operations:
// Animator State -> stateName: "Intro", completeOnAnimationEnd: true
[SerializeReference] [JungleClassSelection]
private IProcess setIdle;
// -> Animator Command with operations:
// Set Bool -> parameterName: "IsIdle", value: true
private void Start()
{
introState.Begin(onComplete: () =>
{
setIdle.Begin();
});
}
}
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 Command" to "Playable Director Command" and adding the appropriate operation - no code modification required.