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

Unity 5.2 Mecanim Transitions not working the same as 5.1

Discussion in 'Animation' started by David-Flook, Sep 9, 2015.

  1. Wiliz

    Wiliz

    Joined:
    Feb 18, 2014
    Posts:
    20
    I have submitted a new bug about this just now. Case number 729936.
     
    Bruce_GMC likes this.
  2. hammil

    hammil

    Joined:
    Jun 5, 2013
    Posts:
    56
    Also done - case #730021
     
    Last edited: Sep 24, 2015
  3. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
    Not sure if this is the same thing as others are seeing or if it's related. Report filed.
    Case 730066) Animation events in 5.2 firing in all blend tree animations at once

    ___


    1. What happened

    After upgrading to 5.2 I saw (or heard) that my footsteps were being called even while idle. I have a blend tree with Idle, Run, and Sprint, with footstep events on both run and sprint.



    It seems while a blend tree is running, the animation will look fine, but it's actually firing events for all animations in that blend tree.





    2. How we can reproduce it using the example you attached

    Create a blend tree with animations , assign events to each animation (I tried a generic event with an int parameter that I set differently based on each animation) Debug.log



    Run the game and watch all the animations firing on a loop (assuming the animations were set to loop)
     
  4. hammil

    hammil

    Joined:
    Jun 5, 2013
    Posts:
    56
    Well, that was fast! I'd imagine we can expect the fix today or tomorrow.
     
  5. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    84
    Hello everyone,

    Well I just submitted the bug case #730415 before I saw it was coming with next patch...
    Anyway, it shows both the transition problem and the blending problem which I thing are linked.
     
  6. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    I don't know if this is related to a bug or not, but I've experienced the issue that transitions are not smoothly interpolated in generic mode, but work fine using a humanoid rig within the same model. Maybe this is nominal behavior (or my misuse), but maybe potential differences in generic vs. humanoid setups could be considered for bug research.
     
    Last edited: Sep 25, 2015
  7. dCoding

    dCoding

    Joined:
    Sep 9, 2014
    Posts:
    26
    Unfortunately 5.2.1p1 doesn't fix my problem. I'll file a bug report / example project at some point, but I just don't have the time right now. I'll be interested to see if this patch solves other people's Mecanim woes.

    [EDIT] It turns out that my problem wasn't Mecanim (at least, not in isolation), but rather it was by animating UI elements that were on nested canvases. For whatever reason, nested canvases behave differently in 5.2.0+ than they did previously. A little more information is found in this thread, which is what led me to the answer:
    http://forum.unity3d.com/threads/nested-canvas-issue-in-5-2.357084/
     
    Last edited: Sep 26, 2015
  8. Ghikya

    Ghikya

    Joined:
    Jan 18, 2014
    Posts:
    4
    I've tested a little my project with 5.2.1p1, and can confirm that this problem(Mecanim Transitions not working the same as 5.1) was fixed for me, at least transitions now are smooth and behave like in 5.1.3p3, so no problems so far.
     
  9. mogwhy

    mogwhy

    Joined:
    Nov 20, 2014
    Posts:
    36
    doesn't fix the blending problem for me. the shoes are still walking in idle
     
  10. Sake906

    Sake906

    Joined:
    Mar 27, 2014
    Posts:
    45
    I'm afraid I will have to inform that 5.2.1 does not solve the animation blend problem; just tried it and the transitions still glitch all over the place, it looks similar to a gimbal lock, as if they are no longer using quaternions for the blending itself...

    Rolled back to 5.1.3, I really hope this is fixed, because otherwise it breaks everything regarding animation.
     
  11. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    Is this still repro in 5.2.1 p1? I am thinking about upgrading or rather shall wait for 5.2.2
     
  12. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    I still have the same issue in 5.2.1p1
     
  13. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    84
    I didn't have enough time yet to completely verify that this is fixed in our project but on the bug report I made, the issue is fixed in 5.2.1p1.
     
  14. phasiclabs

    phasiclabs

    Joined:
    Nov 13, 2013
    Posts:
    126
    THIS.

    I've just upgraded from 5.1.3 to 5.2.1p1, and all of my UI elements that use MecAnim to fade in (animating a Canvas Group component's Alpha) are partially faded in on the first frame of the transition now. They then become completely transparent on the second frame and proceed to fade in as normal.
    I've checked my animations and transitions and they all look correct. They worked fine until upgrading.

    EDIT : A workaround seems to be to do something like this on Awake() :

    m_animator = GetComponent<Animator>();
    m_animator.SetTime(0.0f);
    m_animator.Update(0.1f);

    Of course this will only work if it doesn't matter to you about the animation being slightly updated.
     
    Last edited: Sep 29, 2015
  15. phasiclabs

    phasiclabs

    Joined:
    Nov 13, 2013
    Posts:
    126
    Reported - case 731163
     
  16. Bruce_GMC

    Bruce_GMC

    Joined:
    Oct 23, 2014
    Posts:
    65
    Our blends are now working properly, thanks for your hard work guys.
     
    theANMATOR2b likes this.
  17. mccameron

    mccameron

    Joined:
    Oct 13, 2013
    Posts:
    1
    Last night I upgraded from 5.0.1 to Unity 5.2.0f3 and am noticing the blend tree problems mentioned in this post.

    My main character uses mecanim humanoid animations, and most of them work fine in Unity 5.2.0f3, except for the running animation which uses a blend tree to blend between 3 different animations.

    The running(blend tree) animation looks all wonky in Unity 5.2.0f3, with the rotation of the character off and movement of the limbs a little bit jerky.

    I reinstalled Unity 5.0.1 and opened a backup of my project and it works fine so this problem is specific to the newer version.

    Does anyone have a bug number for the blend tree problem so I can track this or confirmation that it is fixed in the latest version Unity?
     
  18. Nik-Space

    Nik-Space

    Joined:
    Mar 21, 2013
    Posts:
    4
    I find the same issue on regular transition not just on blend trees.
    This animations are Generic and made for this model. (Separated FBXs)
    This is the same project opened in different Unity versions.
    And for some reason this happens always on the left hand.
    But in 5.1.0f3 works flawless. Should i report this as a bug ??

    Sorry for the huge GIFs.

     
    Manny Calavera likes this.
  19. Bruce_GMC

    Bruce_GMC

    Joined:
    Oct 23, 2014
    Posts:
    65
    You should probably update to 5.2.1p1 and see if Unity's updates to Mecanim have addressed your issues first because as this whole thread already understands, 5.2.1f1 does in fact have an issue with blending animations. xD Good Luck!

    https://unity3d.com/unity/qa/patch-releases/5.2.1p1
     
  20. Nik-Space

    Nik-Space

    Joined:
    Mar 21, 2013
    Posts:
    4
    Thanks for the response.
     
    Last edited: Oct 1, 2015
  21. SLD

    SLD

    Joined:
    Oct 1, 2015
    Posts:
    2
    The gif's
    Nik-Space's Gif shows the exact same issue I have. Funny too, cause just like in his animation/model, mine is only glitching on the Left Arm. All of my transitions suffers from this glitchiness, regardless of the transition duration, and only ever on the left arm. I wasted about 14hrs attempting to fix this on my own, and have tried every possible transition setup/option, but nothing I tried seemed to help at all in fixing this twitch.

    The twitch happens on the first frame after the midway point of the transition. So the first frame after being 50% blended. It seems to be a strange rotation issue that only happens at that exact time (transition half way point), that is not fixable by me no matter what I try. :(

    Note: I just updated my Unity from 5.2 to 5.2.1 today and the problem still exists. It is driving me nuts, please fix this.
     
  22. SLD

    SLD

    Joined:
    Oct 1, 2015
    Posts:
    2
    I downloaded patch version 5.2.1p2 after making the comment above.

    The twitch is GONE. My transitions are now nice and smooth, looking very nice. Thank you for fixing this annoying bug, you put a smile on my face. :)
     
    theANMATOR2b likes this.
  23. Bruce_GMC

    Bruce_GMC

    Joined:
    Oct 23, 2014
    Posts:
    65
    5.2.1p2 doesn't contain any changes to mecanim, it's likely the fix you were requesting was released in patch 1. Which was released last week.. :rolleyes:
     
  24. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
    same problem here character breaking and going inside the base ,unity tech need to fix this bug please.on 5.3
     
  25. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
    i hope it can solve in 5.3 release .can i know 5.3 full version official release from beta
     
  26. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    The fix should be available in 5.3 too. We always fix the bug in the most latest version first and then backport to previous version
     
  27. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    844
    Updated to 5.3 but still having similar problems. I did notice something though: Updating the animator.speed seems to be applying the speed modifier twice (perhaps from multiplying by the variable in 2 distinct places).
    Example: If you set animator.speed to 3, it will act like the speed is 9. If you set it to 0.5, it will act as it is 0.25 (0.5 * 0.5).

    This was causing several inconsistencies especially during animation transitions. I found this by counting the number of frames the animation has versus the applied speed. Multiplying it by 2 would always end half way through the predicted frames.

    I also tried this solution (provided by you) to apply speed from parameters, but the results are just as odd.

    I can provide an example if you need it. Hope this helps.
     
  28. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Yeah please log a bug and send me the bug number once you get it
     
  29. manutoo

    manutoo

    Joined:
    Jul 13, 2010
    Posts:
    522
    My creatures are still jerking around in 5.2.1p3 ... :( (and no, I don't have time to make a repro, I'm back to 5.1.3p3)
     
  30. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    844
    I may have jumped into conclusions a little too early. Give me a few more days. I'll see if I can better narrow down the cause.
     
  31. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    844
    Ok finally, I found the bug and a solution for it. The issue seems related to an already reported bug (2 actually), but the instructions weren't clear enough.

    In a nutshell, animator.speed seems to be taken into consideration when calling animator.Update. As a result, if you attempt to control the animation flow of your project, your current animator speed will interfere with the results, causing all sorts of trouble.

    The fix is rather simple procedure. Replace this:
    Code (CSharp):
    1. animator.Update(Time.fixedDeltaTime);
    With this:
    Code (CSharp):
    1. animator.Update(Time.fixedDeltaTime / (animator.speed > 0? animator.speed : 1));
    Or, in simpler terms:
    Code (CSharp):
    1. if (animator.speed > 0){
    2.        animator.Update(Time.fixedDeltaTime / animator.speed));
    3. }else{
    4.        animator.Update(Time.fixedDeltaTime);
    5. }

    This behaviour is present in both 5.2 and 5.3, however I don't know if this was intentional or not. Would you still like me to log it as a bug?
     
    Last edited: Oct 13, 2015
  32. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    84
    Isn't that intended behaviour ?
     
  33. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    844
    I don't think it was. animator.speed is already being applied regardless. Using the current iteration of animator.Update literally forces the applied speed twice with no control from the user.
    But regardless, that's why I asked if I should report it. This behaviour was not present before 5.2, and it wasn't documented anywhere. For anyone using animator.Update, this was probably a living nightmare to deal with.
     
    Last edited: Oct 13, 2015
  34. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    @MMind If you want to update the animator manually you should make sure that the animator component is disabled otherwise the engine will also tick the animator component with the same delta time.

    Effectively animator.speed do scale the delta time each time animator.Update is called. This is the expected behaviour.
     
    theANMATOR2b likes this.
  35. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    844
    Yes, I'm quite aware of that =)

    I've made the simplest possible project and tested on both 5.1 and 5.3. The problem is very clear. I'll try explaining it the best I can.
    The gif's below show the same project being opened by different versions of Unity:

    Unity 5.1:



    Unity 5.2 & 5.3:

    Here is a screenshot of the entire project:
    http://screencast.com/t/KqXqlGIT

    Here is the full project:
    http://www.ufe3d.com/downloads/mecanim_update.rar

    And this is the script (attached to each character):
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class AnimationControlDemo : MonoBehaviour {
    4.  
    5.     public float animSpeed = 1f;
    6.     private Animator animator;
    7.  
    8.     void Start () {
    9.         animator = gameObject.GetComponent<Animator>();
    10.     }
    11.  
    12.     void FixedUpdate() {
    13.         animator.speed = animSpeed;
    14.         if (!animator.enabled) animator.Update(Time.fixedDeltaTime);
    15.     }
    16.  
    17.     void OnGUI() {
    18.         int cLocation = Screen.width - 180;
    19.         if (gameObject.name == "Constructor_Enabled"){
    20.             cLocation = 30;
    21.         }
    22.         GUI.BeginGroup(new Rect(cLocation, 10, 200, 200)); {
    23.             GUILayout.Label("Animator Enabled = " + animator.enabled);
    24.             GUILayout.Label("Speed (" + animSpeed + ")");
    25.             animSpeed = GUILayout.HorizontalSlider(animSpeed, 0, 5f);
    26.         } GUI.EndGroup();
    27.     }
    28. }
    I'm essentially having two Mecanim instances running concurrently. One has the animator enabled, the other disabled. When disabling the animator we force a controlled update with animator.Update.
    Notice the 0.3f speed looks a lot slower on the second character (Constructor_Disabled). That is because the speed being applied is actually 0.09f (.3f * .3f). A similar effect will occur if you set the speed to 2: The left one will run at 2, the right one will run at 4.

    Then this change should definitely be documented somewhere. As I mentioned before, whoever is using this approach is now losing their hair trying to figure this out.

    It's clear that the changes made on 5.2 are effectively causing the applied speed to be triggered twice when using animator.Update, and there is no other way to fix this other then canceling the applied speed by dividing the value (aka, my previous solution).

    I wish I could go more in-depth, but the Animator class accessibility is a bit limited.
     
    Last edited: Oct 15, 2015
    Tethys likes this.
  36. Alima-Studios

    Alima-Studios

    Joined:
    Nov 12, 2014
    Posts:
    78
    same problem on 5.2.1

    any update on this ?
     
  37. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Log a bug with your project and the repro step and we will fix it
     
  38. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    844
    Done:
    737582 (Open) animator.Update speed inconsistency
     
    Last edited: Oct 20, 2015
    Mecanim-Dev likes this.
  39. Alima-Studios

    Alima-Studios

    Joined:
    Nov 12, 2014
    Posts:
    78
    seems to work on 5.2.2f1
     
  40. Aedous

    Aedous

    Joined:
    Jun 20, 2009
    Posts:
    244
    I'd just like to point out that setting the Animator Component speed to 0f at runtime will cause all gameobjects that use Mecanim to stop responding. I'm not quite sure what is happening but it seems that all the layers are reset back to the Base Layer.
    I'm using Unity 5.2.2p3 and just noticed this when I freeze enemies in the game using a skill.

    EDIT: My current workaround is to set the animation speed to something else apart from 0f, for example 0.0000001f something slow enough to make it seem like it's stuck in place.
     
    Last edited: Nov 18, 2015
    theANMATOR2b likes this.
  41. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    I am still having this problem in 5.2.2p4. Is this supposed to be fixed yet?

    I will try the workaround @phasiclabs suggested.
     
  42. Manny Calavera

    Manny Calavera

    Joined:
    Oct 19, 2011
    Posts:
    205
    Upgrading from 5.2.1f1 to 5.3.0f solved this issue for me. Just wanted to share.
     
  43. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    Is 5.3 publicly available? How stable is it at the moment?

    We'd really like to upgrade past 5.1 before our Christmas App Store submission, but updating Unity has proved to be a risky business in the past.
     
    Tethys likes this.
  44. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    Just tried the 5.3 RC1 and it's not fixed for me. I still get flickering on the first frame of animations where everything should be hidden.
     
  45. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    @Gizmoi, maybe you should log a bug with your project, you may have found another incarnation of the bug.
     
  46. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    I can't upload my project unfortunately, my company won't allow it. I realise how unhelpful this is.

    It seems to happen less in 5.3 RC1, but not gone completely.
    On scenes that are relatively light (therefore don't have much AwakeFromLoad time) it seems fine, where are screens that are UI-heavy it still happens on.
     
  47. BigSeal

    BigSeal

    Joined:
    Jul 2, 2010
    Posts:
    26
    Nevermind, the following is fixed in 5.2.3p1!

    _________________________________________________________
    I found yet another problem. Transform masks for generic rigs do not work within Blend Trees. For example, if I have an animation that has a transform mask for only the characters right arm, the right arm portion will play properly, but all the other bones that were supposed to be masked out will play anyways, but at their default positions (in a T-pose usually).

    This is very easy to reproduce, just make an animator controller with two layers, have the base layer play an animation using all bones, like a walking animation or anything. On the second layer, have a blend tree with two animations in it, the default "Blend" float parameter will suffice. Have two motion fields in the blend tree, one with an animation using a transform mask and one without, using the same animation data. With the game running change the "Blend" parameter in the animator so that the second animation in the blend tree plays (the one with the transform mask). The transform mask will fail to work and will either produce the same animation as the first animation (with no mask), or the bones will be set to the default position.

    If there is only one animation in the blend tree, and that animation uses a transform mask, the mask will work. While the game is running, adding a second animation that does not use a transform mask will immediately cause the mask of the first animation to fail, even if the second animation is not set to play.
    _________________________________________________________
     
    Last edited: Nov 30, 2015
  48. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    could you log a bug with a project exposing the issue?
    best regards
     
  49. JOHNMCLAY

    JOHNMCLAY

    Joined:
    May 23, 2012
    Posts:
    38
    Hey there,

    I'm experiencing this bug also...

    For me the flicker occurs when 2 animation states are transitioning (animA -> animB), then when another animation state is Crossfaded during this transition (animC), the transition immediately cancels and starts transitioning animA -> animC.

    So if (animA -> animB) is 70% through, it will snap from the blended animation, to animA -> animC at 0% through, in a single frame... hence the flicker!

    I hope this sheds some light on the issue!
     
  50. mogwhy

    mogwhy

    Joined:
    Nov 20, 2014
    Posts:
    36
    @JOHNMCLAY: Do you still have this issue with the latest 5.3.1 ?

    anybody else? mecanim still broken?