Building an animation state machine