• RuntimesGodot
  • [GDExtension] How to apply time scale to animation and take effect immediately?

I use spine.get_animation_state().set_time_scale(5.0) in my code, but time scale 5.0 will take effect only after animation changed.

I put some check prints before and after the above line of code:
print("old spine time scale: ", spine.get_animation_state().get_time_scale()) ==> 1.0
spine.get_animation_state().set_time_scale(5.0)
print("new spine time scale: ", spine.get_animation_state().get_time_scale()) ==> 1.0 (should be 5.0)

Related Discussions
...

The issue you're experiencing with the time scale not taking effect immediately when using spine.get_animation_state().set_time_scale(5.0) might be due to the way the animation state is being updated or applied. In the spine-godot runtime, changes to the animation state, such as setting a new time scale, may not be reflected until the next animation update cycle. To ensure that the time scale change takes effect immediately, you can try manually updating the animation state after setting the time scale. This can be done by calling the update method on the animation state with a small delta time, which will force the animation state to process the change:

spine.get_animation_state().set_time_scale(5.0)
spine.get_animation_state().update(0)  # Force an update to apply the time scale change

This approach should help in making the time scale change take effect immediately without waiting for an animation change.

spine.get_animation_state().update(0) tried this already, it's not working

Never mind, it's the fault of my other piece of code, spine is correct on this 🙂

  • NateMisaki 님이 이 게시물을 좋아합니다..