- Home /
Animation motion on base layer does not play after additional motion on second layer
I apologize for the length of this question, but I could not figure out how to ask it without a substantial amount of context.
I'm working on a project where we're using Unity's animation system to animate some UI elements. In several cases we want to have a base UI animation, and play additional simultaneous UI animations based on various animation triggers. I am attempting to use animation layers to do this, however when I play an animation on a layer other than the base layer, all future base layer animations appear to cease functioning.
I have set up and attached a simple sample project that simulates the use case (I had to strip out the library folder to fit under the upload limit). While the sample scene is running, if the user presses any key (or clicks with the mouse), a simple animation will start. This animation is intended to enable a small red sprite, moves it a short distance in the X & Y direction, then enable a small blue sprite, moves it a short distance in either the X or Y direction, then move both of those sprites back to the origin and disables them.
I have set up the animation state machine for this animation thusly:
The BaseState has no motion attached.
RedSpriteIn enables the red sprite and moves it to (5,5). A behavior is attached to RedSpriteIn that randomly generates a number 0 or 1. If a 0 is generated the state machine transitions to BlueXIn. If a 1 is generated the state machine transitions to BlueYIn.
BlueYIn enables a blue sprite and moves it to (0,5).
BlueXIn enables a blue sprite and moves it to (5,0).
RedSpriteOut moves the red sprite to (0,0). A behavior is attached to RedSpriteOut that sets the trigger "RedOutStateBegin" in the animation parameters.
SpritesOff waits 60 frames and then disables both the red and blue sprites.
In addition I have two other, nearly identical, layers in the state machine. These two layers each have an empty animation state as the default state, which transitions to a state the moves the blue Sprite to (0,0) either from (0,5) or (5,0) as appropriate.
All of this functions as expected, until I get to the SpritesOff state. After the animations in the layers play, the animation in SpritesOff does not play. Disabling the animations in the layers prompts the correct behavior from SpritesOff, but, obviously, that means the animations in the layers do not play properly.
I know this problem can be solved by removing the layers and adding additional states, but I am hoping to avoid that as it forces our artists to create multiple animations that are almost but not quite identical. I want to be able to play two animations simultaneously in the same state machine. Any advice would be appreciated.