🎞️ Integration with AnimationPlayer (Cinematics and State Machines)¶
By combining SpriteStudioPlayer2D with Godot's standard AnimationPlayer, you can integrate SpriteStudio animation playback with Godot's powerful timeline and state machine features.
This enables you to visually perform tasks such as synchronizing attack hitboxes, triggering sound effects (SE), shaking the camera, and creating cutscenes without writing complex code.
1. Generating an Animation Library¶
To control SpriteStudioPlayer2D with an AnimationPlayer, you must first convert all animations (e.g., walk, attack) contained in the target .ssab file into an AnimationLibrary (_anims.res) that Godot can read.
- In the Godot editor, select the
.ssabfile from the FileSystem dock. - Click the "Gen AnimLib" button at the top of the Inspector, next to Reconvert.
- Upon success, a file named
[original_filename]_anims.reswill be generated in the same directory.
Note
The generated _anims.res automatically contains "Value Tracks" with the exact same names as the original SpriteStudio animations. These tracks control the current_animation (animation name) and frame_no (playhead) properties of the target node.
When the Animations Change¶
Reconvert does not rebuild _anims.res. After you add, rename or delete animations in SpriteStudio, or change their frame count or FPS, press Gen AnimLib again after Reconvert. Until you do, new animations are missing from the AnimationPlayer, renamed and deleted ones stay in its list, and lengths and speeds stay as they were. An AnimationPlayer in an open scene picks up the new library as soon as you press it. Edits to poses and motion alone need only Reconvert: _anims.res holds just the animation names, lengths and frame numbers.
Warning
Gen AnimLib rebuilds _anims.res from scratch. Tracks you added to its animations (Advanced Use Cases) are lost when you press it again. Copy them first with Edit > Copy Tracks... in the Animation panel, and put them back with Paste Tracks afterwards.
2. Setting Up the AnimationPlayer¶
Here is how to apply the generated library to your scene.
- Prepare the Node
Place a
SpriteStudioPlayer2Dnode in your scene, assign the target.ssabfile to itsSsabproperty, and turn Autoplay off. TheAnimationPlayerdrives the playhead, and a node that also plays itself fights it every frame (see Driving from an AnimationPlayer). - Add an AnimationPlayer
Add an
AnimationPlayernode to the scene. - Specify the Target (Important!)
Select the added
AnimationPlayernode and set itsRoot Nodeproperty in the Inspector to theSpriteStudioPlayer2Dnode from step 1. Note: Since the generated animations are configured to control thecurrent_animationandframe_noproperties of the target node itself, the Root Node must point directly to theSpriteStudioPlayer2Dnode. - Load the Library
Open the "Animation" panel at the bottom of the editor, click the "Animation" menu > "Manage Animations...".
Click the folder icon (Load Library) in the dialog that appears, and load the generated
_anims.resfile.
You will now see a list of all animations created in SpriteStudio directly in the AnimationPlayer dropdown!
3. Advanced Use Cases¶
Once integrated with AnimationPlayer, you unlock several advanced control methods:
A. Synchronizing with Events and Sound Effects (Call Method Track / Audio Track)¶
Add a "Call Method Track" or "Audio Playback Track" on the AnimationPlayer timeline.
You can visually and perfectly sync the exact frame a character swings a sword with playing a sound effect or calling a GDScript function like enable_hitbox().
B. Using State Machines (AnimationTree)¶
Add an AnimationTree node to the scene and assign the aforementioned AnimationPlayer to its Anim Player property.
By setting the Tree Root to AnimationNodeStateMachine, you can visually construct state transitions (e.g., Idle -> Walk -> Attack) using a node-based interface instead of writing complex logic in code.
C. Cutscenes and Cinematics¶
By adding tracks that move the camera (Camera2D), change background colors, or trigger other visual effects, you can create fully synchronized event scenes (cutscenes) all within a single timeline.