Animation State Machine
By Jordan Calderwood
This week was technically our spring break, but I wanted to get our player animated so we can start to see the vision of our first game play build as soon as possible. In order to do that, I need to design a simple animation state machine to be able to handle all of the scenarios required to animate the different player actions. Here is the functionality I implemented into the system:
1. Ability to play an animation once per event trigger.
2. Ability to play an animation continuously until triggered to stop.
3. An animation state object that contains a list of transitions to other animation state objects. This object contains information on whether the animation loops, whether it can be interrupted, as well as the list of transitions.
4. An accompanying transition object that contains information about which animation to transition to, the duration of the transition, and whether the unique transition can be interrupted.
5. Animation trigger and bool objects that can be set by the animation system that cause the state machine to transition between states.
Because of the lack of a graphical tool, the system requires manually setting up each animation state object and adding each transition one-by-one to each state. This was tedious at first but ultimately made debugging the system much easier since I could identify where any breakdowns occurred.
Initially, I had trouble controlling the flow of the animation states, and managing the animation triggers. The system became convoluted as I was trying to use a single method to play the animations, both for looping and non-looping animation states. I then separated these two functions which allowed me to visualize the path of each transition in the state machine. The two methods share a bulk of their code, which irks me as a programmer, but keeping separate helped me isolate them in my mind as I was implementing the rest of the functionality. Maybe I will go back and combine them now that the system works properly, just to get rid of some extra lines of code.
The animations are now working pretty nicely. I can move the player forward and back, strafe side to side, and wind up and throw in separate stages. Check out the video for a little demo of how it turned out after this first week of working on it.
Comments
Post a Comment