It sounds like you are encountering an issue where IK and Transform constraints are not being properly reset when an animation is set to empty. This can happen if the constraints are not explicitly keyed in the empty animation, or if the constraints are not being reset correctly when the animation is cleared.
Here are a few steps you can take to troubleshoot and potentially resolve this issue:
Ensure Constraints are Keyed in Empty Animation: When you set an animation to empty, make sure that the empty animation explicitly keys the constraints to their default state. This ensures that the constraints are reset when the empty animation is applied.
Check Mix Duration: Ensure that the mix duration is set correctly when transitioning to the empty animation. A mix duration that is too short might not give enough time for the constraints to be reset properly.
Update World Transform: After applying the empty animation, make sure to call skeleton.updateWorldTransform()
to ensure that all bones and constraints are updated correctly. This is crucial for ensuring that the skeleton's state is fully updated.
Debugging: Add debug logs to check the state of the constraints before and after applying the empty animation. This can help you identify if the constraints are being reset correctly.
Here is an example of how you might set an empty animation and update the world transform:
state.setEmptyAnimation(track, 0);
skeleton.updateWorldTransform();
If you are using the SpineSprite
node in Godot, you can use the following methods to set an empty animation and clear tracks:
spine_sprite.set_empty_animation(track, mix_duration)
spine_sprite.clear_track(track_id)
spine_sprite.clear_tracks()
Make sure to call these methods in the correct order and with appropriate parameters to ensure that the constraints are reset properly.
If the issue persists, consider adding a small delay before setting the empty animation to ensure that the previous animation has enough time to be applied and mixed out correctly.
yield(get_tree().create_timer(0.1), "timeout")
spine_sprite.set_empty_animation(track, mix_duration)
This delay can help in cases where animations are canceled very quickly after being applied.
By following these steps, you should be able to troubleshoot and resolve the issue with constraints not being reset correctly when an animation is set to empty.