AnimationState expects to be played forward, for a number of reason it isn't possible to play backward, or at least some things won't work.
If you have two animations, with one is reversed using selection scaling as Mario explained, you can use code like this:
AnimationState state = ...
function play () {
state.setAnimation(0, "forward", false);
TrackEntry entry = state.addAnimation(0, "backward", false);
entry.listener = play;
}
play();
Obviously the syntax depends on your language. If you have one animation it's simpler:
AnimationState state = ...
function play () {
state.setAnimation(0, "forwardAndBackward", false).listener = play;
}
play();
If your AnimationStateData has a default mix duration, you might want to set the mix duration for these animations to 0.
AnimationStateData data = ...
data.setMix("forward", "backward", 0);
data.setMix("backward", "forward", 0);
// OR
data.setMix("forwardAndBackward", "forwardAndBackward", 0);