loopier / animatron

Animatron for Godot 4.x <
15 stars 1 forks source link

On State Machines #27

Open loopier opened 6 months ago

loopier commented 6 months ago

State machines for animations are easy to handle: when the current animation is finished (reaches the last frame) it emits a signal or calls the next state choosing from the list of possible next states.

For command state machines it's not that obvious. How would we know if the current state is finished? If commands are triggered one after the other, we might need some kind of status controller (maybe the returned Status).

Another issue is how we store the actual behaviour of each state, the list of commands it should trigger. It's similar to a /def if not exactly the same, so we could just map each state to a /def. But how would we handle its variables? The current syntax is:

stateMachine[machine].addState("bla", "foo", "bar") # creates a new state "bla" with possible new states "foo" and "bar"

StateMachine currently uses a Dictionary to store states. Should we add another dictionary to hold the actual commands? See StateMachine.gd

loopier commented 2 months ago

A proto implementation for image sequences using state machines has been implemented in https://github.com/loopier/animatron/commit/eae6ceb66484d1d8d76d43f4daa5ab3eea1756d9 . I used the existing StateMachine.gd to keep it compatible with possible future command state machines.

Animation state machines and command state machines may not have the same workflow. This needs further investiation.