I realize this is super basic, but after looking at various threads and doc pages I realize that something very fundamental about the Animator process is just not clicking for me. I’m sure the answer is right there, but the fastest method at this point is to ask.
I have a baseball (2d sprite) with an animator component and a single animation clip. The clip sends the ball to the center of the screen, spinning it, then increases its size while still spinning, so it looks it’s flying right at the player. (See top sequence in diagram.) The clip ends when the ball fills most of the screen. The clip looks perfect when I look at it in isolation by scrubbing the clip’s timeline.
The ball’s Animator state machine starts in a Wait state with no animation attached. It sits in the Wait state until a trigger fires, at which time it transitions to a Flying state with the clip attached.
Now, I also added a collider2d and rigidbody2d to the ball. In my game, the ball should obey physics most of the time, but at a certain point, after it has fallen to the ground and come to a complete stop, I want a trigger to start the animation clip. Things break when I try to both use physics and then switch over to the clip, though.
-
If I have both enabled a rigidbody2d with gravity (and 2d collider) and also enabled an animator component on the ball, the physics won’t work. Ball just sits there. Animation will play properly when trigger fires, however.
-
Disabling Animator re-enables physics, but I need that clip to play, so no help there.
-
Playing around with the root motion checkbox has led to some strange variant behaviors, like the ball obeying physics and falling properly, but then flying off in a wild spiral (see bottom of diagram), only to disappear, when the animation finally triggers. (I actually don’t know how to reproduce this behavior offhand, but I can try if it helps).
I can test this more comprehensively, but I suspect the answer is obvious to anyone who has worked a little with Mecanim. (If I am wrong about this I will gladly collect more data.)
Thanks in advance for reading this. Can anyone let me know what fundamental concept is eluding me?