Skip to content

AnimatorPlaybackSnapshot Class

Immutable capture of a SpriteAnimator's runtime playback state. Use CapturePlaybackSnapshot() and RestorePlaybackSnapshot(AnimatorPlaybackSnapshot) to save and restore mid-frame position, speed, direction, ping-pong phase, and cross-fade state atomically.

public sealed record AnimatorPlaybackSnapshot : System.IEquatable<Brine2D.Animation.AnimatorPlaybackSnapshot>

Inheritance System.Object → AnimatorPlaybackSnapshot

Implements System.IEquatable<AnimatorPlaybackSnapshot>

Remarks

The snapshot is a value-level copy: it holds the clip name (not a clip reference) so that it survives clip replacement and serialization round-trips. When RestorePlaybackSnapshot(AnimatorPlaybackSnapshot) is called it re-resolves the clip by name; if the clip is no longer registered the restore is a no-op and returns false.

Primary use cases are save/load (rehydrating exact mid-animation state from a save file), rollback netcode (rewinding all game state to a prior tick for resimulation), and cutscene/ability override systems (temporarily hijacking an animator then restoring the interrupted playback state, including any cross-fade in progress).

Cross-fade state (Brine2D.Animation.AnimatorPlaybackSnapshot.CrossFadeAlpha, Brine2D.Animation.AnimatorPlaybackSnapshot.CrossFadeOutgoingClipName, Brine2D.Animation.AnimatorPlaybackSnapshot.CrossFadeOutgoingFrameIndex) is included so that in-progress fades survive a save/load cycle. If the outgoing clip is no longer registered on restore, the cross-fade is discarded and playback resumes from the incoming clip with full alpha.

Constructors
AnimatorPlaybackSnapshot(string, int, float, float, bool, bool, bool, bool, bool, int, float, float, float, float, float, string, int) Immutable capture of a SpriteAnimator's runtime playback state. Use CapturePlaybackSnapshot() and RestorePlaybackSnapshot(AnimatorPlaybackSnapshot) to save and restore mid-frame position, speed, direction, ping-pong phase, and cross-fade state atomically.