Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

360 Rotation Reverts Itself

Discussion in 'Animation' started by Littlenorwegian, Jul 24, 2018.

  1. Littlenorwegian

    Littlenorwegian

    Joined:
    Oct 19, 2012
    Posts:
    143
    This might be a more Blender-related question but affects the mecanim animation system as well.

    Basically, I have a character that rolls. The rig moves 360 degrees on his forward axis then returns to his normal idle animation.





    However, the problem is that the character, upon transitioning to the normal idle animation spins back 360 degrees. It sorta feels the need to revert back, instead of accepting those 360 degrees that just occured


    (You can see the problem occur in Blender too, if I insert the start frames of the idle animation)

    So, is there any way I can make the rig, in Unity or Blender "accept" the rotation and not have it spin back?
     
    Last edited: Jul 24, 2018
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I believe this is caused by the type of animation controller that is controlling the animation keyframes. In 3D Max the artist can set/control the different types of animation controllers to use on individual animated components. The common animation controllers are Euler, Quaternion, and some others which calculate math differently, mostly dealing with rotation and velocity.
    If you can figure out how to change the animation controller on the rig in blender, that should change the results of the animation.
    If you still experience the problem, a "work around" could be on the 360 roll, on the second to last key frame of the roll animation, approximately 359 degrees, rotate the character 359 degrees back in the opposite direction.
    It will appear the character is completely rotating 360 degrees over the length of the animation, but in reality he will be rotating 359 degrees then rotating back 359 degrees from the second to last key frame to the very last key frame.
    That should correct the rotation issue leading into the idle.
     
  3. Goatogrammetry

    Goatogrammetry

    Joined:
    Apr 27, 2017
    Posts:
    196
    I'd sure worry about that 359 degree trick having side effects...

    So I've seen some lame things in Max where a rotation goes skewumpus gimbal-tarded when it shouldnt. Its caused by pasting the keyframe instead of manually rotating it in certain situations (situations which are a mystery to me). So for instance, if I want to make a looping animation and have the first and last frame the same, do the animation and when I near the end I grab frame 1 and paste to frame 30. Bleck, the arm spins in its shoulder socket. Why does pasting do this sometimes? Dunno. I can move it into position manually and its not a problem.

    I'd agree that this is the rotation controller's fault. In max, if I have troubles, sometimes I can swap out the Euler rotator with one of the other choices and it works fine. Whats happening to you is its finding the shortest path from 360 to 0 and coming up with the wrong answer. One thing you might try is making some dummy object do the spin and make sure it correctly transitions betwixt 360 and 0 (doesnt rotate at all) and then slave the root bone of your character to it and force it to comply to your will. Another solution is to punch the screen.
     
    theANMATOR2b likes this.
  4. Littlenorwegian

    Littlenorwegian

    Joined:
    Oct 19, 2012
    Posts:
    143
    Punching the screen sounds tempting :p

    I sorta got something working with the 359 trick, but there is a problem. My animation and game are at 60fps.
    However, if I make the animation clip slower in mecanim (say half speed) then a frame or two of that transition actually appears in there.

    I don't use Max, but rather Blender so I don't have an animation controller in the same way. I can however change it from Quaternion to XYZ Euler.

    Hurrah!

    However, if I change it to that, suddenly all my animations are broken. (Like a lot of rotation data is lost when I convert)

    Haroo...


    Hmmm, I mean, I think I can work out a sort of "dirty hack" solution, but I do wonder what the "professional" way of doing this is. I kinda figure that having characters roll or spin is a fairly common occurrence in game character animation.

    Thank you guys, so far :)
     
    theANMATOR2b likes this.
  5. Goatogrammetry

    Goatogrammetry

    Joined:
    Apr 27, 2017
    Posts:
    196
    The purpose of a rotation controller is to find its way from keyframe to keyframe. It is usually a problem when you rotate 180 and it cant tell if its faster to go to 0 via 0 or 360. The path from 360 to 0 should not be to count down. You know-- the propeller blade problem where you want the damn blade to spin, not bounce back and forth. If Blender wants to act like you're suggesting, then this has to be a very common complaint and I'm sure there's lots of discussion out there. What you may need to do is forget your character and research this via rotating some cubes until you can get your rotations tamed.
     
    Littlenorwegian and theANMATOR2b like this.
  6. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    The pains we have to endure to create beautiful art! :)
    I've experienced all you mentioned more times than I care to admit. Max has a custom inbuilt controller that no other 3D software I know of has called the tcb controller. It is probably one of the worst ever animation controllers because it does not provide curve information, rather numerical values relating to tension, continuity and bias for in/out interpolation from one keyframe to the next. And to top it off - that controller rules every bone in biped. The reason why biped is not the best custom rig to use for any complex characters. - unfortunately.

    The 'professional' way is to use a controller that does not override rotations past 180 degrees. I think xyz controllers do in fact record rotations accurately. I believe that was the solution I used for propeller animations back in the day, (200x).

    I thought you had more animation keys so I did not mention this before.
    Another option rather than going full 359 degrees is to use existing animation controller and key frame at roughly 90 degrees over 4 keyframes then use whichever curve interpolation suits you best. Smooth interpolation might cause some unexpected results, but if comfortable using bezier key interpolation will result in highest fidelity for artist control.
     
    Littlenorwegian likes this.
  7. Littlenorwegian

    Littlenorwegian

    Joined:
    Oct 19, 2012
    Posts:
    143

    I made a little video to explain my problem so you might better see/understand my problem and perhaps offer a solution. I think animation controller, which you guys are referring to is more a 3DS Max than a Blender thing (I don't know, I've not seen anything related to that specific term)

    But yeah, video! Hope it helps in maybe you being able to help me :)
     
    daniel_lochner likes this.
  8. Goatogrammetry

    Goatogrammetry

    Joined:
    Apr 27, 2017
    Posts:
    196
    You could just go in and type in the rotation manually to have 360+ whatever was there on every keyframe past the roll for the pelvis bone... Your clip will work in Unity just fine. I'm pretty sure. I'm guessing you dont need a lot of idle frames past the roll to end up with a good clip.