Short version: I’m trying to play a simple animation that rotates a soccer player 360° around the z axis. This works about half the time, but the other half, the player gets stuck halfway through, and the animation stops prematurely.
In this simple soccer game, the player is either running, standing around, or doing a bicycle kick. Here’s the animation state machine:
The transitions seem to work fine, the running animation plays when the player runs, stops when he stops, and when I hit the bicycle kick button, the bicycle kick animation triggers. The problem occurs during the bicycle kick animation.
This is the transition back from bicycle kick to idle:
This is the only transition going out of the bicycle kick state.
The animation is supposed to play once, then immediately go back to the idle animation and, if the player is running, continue to isRunning. I’m triggering transitions like this:
if (!animator.GetCurrentAnimatorStateInfo(0).IsName(animationName)) {
animator.SetTrigger(animationName);
}
The idle animation is completely empty.
The bicycle kick animation sets the player’s z-rotation to -360 degrees at the beginning, and then rotates him back to 0 degrees:
The player that’s being rotated looks like this:
The reason why there’s a Rotatable GameObject containing a Direction GameObject containing the actual sprites is that I’m using Rotatable to do the bicycle kick animation, and I’m using Direction to turn the player in the direction he’s running.
(I also intend to use these two GameObjects to manipulate the pivot point for the animation, by moving one down and the other one up by the same distance.)
All of this works perfectly about 50% of the time. The remaining 50% of the time, the animation triggers fine, but then gets stuck midway through. Here’s an animated gif showing the effect:
(At the moment, the player rotates “into the ground”, and I intend to also make him jump at the same time by increasing the y velocity, so it looks like a real bicycle kick, but I’m trying to remove all factors that could have an impact on the animation, so that’s not happening in the gif. At any rate, jumping did not help; the problem occurs regardless of whether the player rotates “into the ground” or not.)
Any hints would be hugely appreciated.