I have a default idle state, which transitions into an idle which turns 180deg and walks. In the animator the transition from idle to the turn clip works perfect, showing the character blending from idle to turning 180deg and walking, but ingame, when the turn clip is done the character is not facing the opposite way, maybe like 160deg or so. I made sure the blending is over before the actual turn has started.
1 Answer
1I guess I`ll answer that because I managed to get what I need. How I did it:
- I made two sets of clips: one for turning to the right and one to the left
- Used an AnimationEvent to tell the turn to transition to Walk
The key was that all the clips in the sets had to be “similar” i.e. the first step to be at the same time across all.
Then I chose a time for the event. In the clips for turning left I chose a time after the turn and when the right foot is off the ground. For the other set at the same time not the right but the left foot is off the ground, because the clips are mirrored, so I set the event in the next step where again the right foot is off the ground(which makes the clips from this set a little longer), that way both sets could transition to a single Walk.
I used this approach because I wanted the character to turn to the way the camera is facing and keep walking that way. The result was almost perfect with just a little difference in the Y rotation of the character which I correct from script.
Might help if you said how it was set up (Mechanim? Some tracking button checked set?) Using plain animation (the old system,) animation will never change the actual facing (the blue arrow.) And, it will always be perfectly positioned as in the last frame (unless the blend time is longer than the animation.) So something else is chopping yours short.
– Owen-ReynoldsYeah it's mecanim :)
– apomarinov1I thought it was the blending that caused this. So some of the rotation would be lost blending from idle->turning and some more will be lost turning->walking. You've ruled out the first but maybe it's happening in the second transition? You might want to check out Animator.MatchTarget. This allows you to specify the exact rotation you want to achieve at a given point during the animation. [Animator.MatchTarget][1] [1]: http://docs.unity3d.com/Documentation/Manual/TargetMatching.html
– karlhulme