How to play the same animation multiple times?

I’ve run into a problem I can’t seem to resolve nicely.

I have a character which can react to “slaps” by playing back an additive get-hit animation. However he can be slapped quite frequently and I want each slap to get a slap reaction. But sending a crossfade call to the same animationstate just makes the current animation keep playing.

What I’m looking for is a way to make an animation blend to itself. In other words if “slap_left” animation is playing, and is called once again, the first playing version should blend out, while the same animation blends back in at time 0.0.

Setting time or rewinding it is too snappy, and the other solution I’m considering now is to have duplicates of the same clip and call them slap_left1 and slap_left2, but that seems a bit hackish.

I believe what you want is CrossFadeQueued with PlayNow mode:

  animation.CrossFadeQueued("slap_left", 0.2, QueueMode.PlayNow);

Yes, that sounds contradictory, I guess they should have called it “CrossFadeDuplicate”.