Time for action – animation interrupts
The trouble is that we're telling the character to play his "catch"
animation when he collides with a stein, but it's not happening. We see, at best, the first frame of that animation, and then it's interrupted by either the "idle"
or "step"
animation:
Luckily, we can add a condition to the script to prevent these glory-hog animations from playing if we're trying to catch a beer stein. Dip back into your CharacterScript and make these changes:
if(lastX != transform.position.x) { if(!isMoving) { isMoving = true; if(!animation.IsPlaying("catch")){ animation.CrossFade("step"); } } } else { if(isMoving) { isMoving = false; if(!animation.IsPlaying("catch")) { animation.CrossFade("idle"); } } }
By wrapping the
animation.Play
calls in theseanimation.isPlaying
conditionals, we can ensure that the character isn't busy playing his catch animation when we determine it's time to step or idle. Remember that!Save the script...