I understand you're experiencing intermittent freezing for 2-3 frames when restarting Spine animations in Unity. This is a tricky issue to diagnose without more information, but here are several potential causes and solutions:
Potential Causes and Solutions:
1. Timing of SetAnimation Calls
The most common issue is calling SetAnimation() at the wrong time in Unity's update cycle. Make sure you're:
- Not calling
SetAnimation() every frame (which you seem to be avoiding already)
- Calling it at the appropriate time in your update cycle
- Not modifying the skeleton immediately before or after the call
2. Animation Clean Up Export Setting
I notice from your export settings screenshot that Animation clean up appears to be enabled. This setting removes keys that are identical to the setup pose, which can cause issues when layering animations or restarting animations. Try:
- Disabling Animation clean up in your Spine export settings
- Re-exporting your skeleton
- Reimporting in Unity
3. First Frame Issues
If the animation is freezing on a specific pose, it could be related to how the first frame is being handled. You might want to try:
var entry = skeletonAnimation.AnimationState.SetAnimation(0, animation, isLoop);
entry.TrackTime = 0; // Explicitly set to first frame
Or enable holdPrevious if you're transitioning from another animation:
entry.holdPrevious = true;
More info: TrackEntry.holdPrevious
4. Profiling the Issue
To better understand what's happening, I'd recommend:
5. Send Us a Minimal Project
If none of these suggestions help, we'd be happy to investigate further. Could you send us a minimal Unity project that still demonstrates this issue? You can send it as a zip file to contact@esotericsoftware.com, briefly mentioning this issue so we have context.
Please include:
- Your exact spine-unity runtime version (found in
Assets/Spine/version.txt)
- The problematic skeleton files (the three exported files: .json/.skel.bytes, .atlas.txt, and .png)
- A simple script that reproduces the freezing behavior
This will allow us to reproduce and fix the issue directly.