Closed Shadowblitz16 closed 1 year ago
When an animation player state is activated it will automatically start the configured animation in the linked animation player. The animation player has a signal animation_finished
which you can listen to and then send an event to the state chart. Then a transition inside the animation player state can listen to this and transition elsewhere.
In this example I have two states one plays an animation RotateLeft
and the other one plays an animation RotateRight
. Both states have a transition to the other state which listens on the animation_player_finished
event. I also have connected the animation_finished
signal of the animation player to a function which will send the animation_player_finished
event to the state chart:
Now when the scene starts this happens:
_on_animation_player_animation_finished
method will be called and sends an animation_player_finished
event to the state chart. _on_animation_player_animation_finished
method will be called and sends an animation_player_finished
event to the state chart. https://github.com/derkork/godot-statecharts/assets/327257/49af4999-0096-4c1a-8811-a9c1b62fecdc
Here is the scene for you to try out: test.tscn.zip
I hope this helps.
thankyou
I would like to add to this, for those of you who do not use Animation Player States but would like similar functionality.
I've had good luck so far with adding a Call Method track on the last frame of an animation I want to transition to another state by invoking the send_event
function with a StringName
argument containing whatever value would cause the transition from the current state.
Hope that's helpful to someone!
How do I use animation player states and transitions to travel to a state when the animation is over?