Not certain that this is the optimal method but it could certainly be done this way:
Add an AnimationTree, add a NodeBlendTree and select your animation player. Add the node structure as:
Animation --> TimeScale --> Seek --> Output
In the AnimationTree script make method along these lines:
var playing_segment = -1
if playing_segment == -1:
playing_segment = start
Then to stop the animation add a Call Method Track in your animation player calling a stop_segment() method in your animation tree. You can use the playing_segment value to add some logic here and make sure the right animation stops in the right place depending on which segment is playing. Remember to reset it to -1 when you’re done.
Here are the docs for animation_tree if you’re not familiar with it:
This is really unnecessary. A Call Method track by itself would suffice.
Rodeo | 2022-01-18 13:25
My suggestion did use a Call Method Track in exactly the way you suggested.
I also added the AnimationTree to have the additional functionality of being able to start as well as stop the animation at any point, something I thought the OP might find useful.
DaddyMonster | 2022-01-18 14:38
AnimationPlayer already has methods advance() and seek() and a property current_animation_position. You could acheive the same thing without the added complexity.
Rodeo | 2022-01-18 20:46
Making a basic animation tree is not complex, it literally takes a few seconds and allows for easy and convenient control which is infinitely more scalable and manageable than relying on an animation player alone.
Regardless, I prefaced my suggestion with Not certain that this is the optimal method but it could certainly be done this way:
If you believe you have a better approach then perhaps next time just leave your own suggestion on a separate thread and let the OP decide which approach they prefer rather than sharing your opinion on a perfectly valid approach from another user. And maybe also check that what you are suggesting hasn’t already been covered.