Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Animator Cannot Get Rotation Right

Discussion in 'Animation' started by Johny_G, Jan 23, 2015.

  1. Johny_G

    Johny_G

    Joined:
    Mar 28, 2014
    Posts:
    20
    Hi guys! I have a problem with Animator that's been bugging me for weeks. I've spent so many hours trying to resolve it that I'm starting to be desperate.

    We are working on turn-based game with characters moving within fixed grid. The characters have to move exactly from the center of previous square to exact center of the next one. After a lot of thinking and tweaking we were able to almost perfect the walking animation (so some smoothened correction is completely acceptable), but the rotation is pretty much a nightmare.
    • Animation rotates the character exactly 90 degrees. Not more, not less.
    • Both sides of the rotation clips have safe areas with fixed root node that is being used for animation blending/tweening - just to be sure that none of the rotation is cut out by the idle state.The rotation only happens inbetween.
    • We have tried to open the exported FBX in 3ds max again, and it turns exactly 90 degrees.
    • When imported to Unity, it can do about 89.15 degrees (i.e. turning from 180 to 269.1519), resulting into annoying corrections after every single rotation. We have to do those since otherwise the character would walk in angle and miss the center of the other square.
    • The clip settings are attached - we always bake the things we don't use, so it doesn't collide with the correction system (Y translation for everything, rotation for everything but Turns and XZ for everything but Walk). If we don't, it gets even worse.
    • We have also tried to animate geometry to see whether it is wrong in the preview window as well. And it is (as attached).
    Do you, please, have any idea how to resolve this? Thank you so much!

    unity_animator_clip_settings.PNG unity_animator_before.PNG unity_animator_after.PNG
     
    Last edited: Feb 5, 2015
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Hmmm - this is odd.

    My initial guess is the original animation - though you think was correctly animated at 90 degrees - wasn't really - instead was animated to 89.15. Do you have angle snap ability in your original animation package to 100% confirm the animation was created correctly? Animate another object with snap on and test in Unity inside your current system to confirm the problem is in Unity.

    I assume the turn was animated with two keyframes from angle 0 to 90 over a specified time (say 30 frames/1 second).
    Could you perform a test to create the turn with 3 keyframes instead of 2.
    Keyframe 1 set at 0 degrees
    Keyframe 2 at (frame 15) set to 45 degrees (smooth interpolation)
    Keyframe 3 at (frame 30) set to 90 degrees.
    So performing the same rotation but with 3 keyframes instead of 2 keyframes.
    Export and put into your system in Unity to see if it works as intended.
     
  3. Johny_G

    Johny_G

    Joined:
    Mar 28, 2014
    Posts:
    20
    I have checked it with our animator, and the real characters use key-per-frame, so there is no real reason for this weird behaviour. But there is some other news. It seems, that the issue is Unity 5 specific. Screenshots below:

    unity_animator_4_ok.jpg unity_animator_5_incomplete.jpg

    I'm a little worried about that since it's too late to switch back for us :-(.