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.

Mecanim Control

Discussion in 'Assets and Asset Store' started by Mistermind, Jan 24, 2014.

  1. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Hi there
    Unfortunately the current version of Mecanim Control isn't supported in Unity 5 Beta.

    The error message you are getting is the fact that MC2 uses hidden libraries, which is the reason why you cannot compile projects using that tool. On Unity 5 they moved those libraries out of that class.

    When Unity 5 becomes official I'll update the tool ( as mentioned in the message right above yours ;) )
     
  2. Ceraph

    Ceraph

    Joined:
    May 16, 2013
    Posts:
    19
    Hello, I recent bought Mecanim Control and am using it for my project. For the most part it has been working perfectly, but I am noticing a very strange bug when trying to play animations sometimes. As near as I can tell the way to reproduce this issue is by having the call to Play() generated by an AnimationEvent on the animation's timeline.

    The bug I'm seeing is that all the values of the transforms for the bones of the character seem to be getting set to 0 for the first frame after the call to Play() happens. It doesn't make a difference if there is any blending applied or not, the first frame of the new animation is always zeroed out, and then the following frame the animation starts to play. I have attached screenshots of my character's animation frame by frame as the bug happens. The first shot is the frame right before the call to Play(), the second shot is the frame right after the call to Play(), and the third shot is the frame immediately following (the expected result). Any idea what might be causing this or how to fix it?







    Thanks,
    ~ Ceraph

    EDIT: If anyone else is running into this issue I have created a workaround that is working for the time being. I changed my code that gets called by the AnimationEvent to set a bool, then just check the bool inside update to see if it should play the corresponding animation. There doesn't seem to be any visible delay by using this method, but it is a little more complicated than I would like.
     
    Last edited: Nov 17, 2014
    CWolf likes this.
  3. crandellbr

    crandellbr

    Joined:
    Apr 3, 2013
    Posts:
    117
    You promised to keep us updated (Post #47), but nothing has been said about animation layers since...that was nine months ago. I don't understand how this asset can be considered complete without the capacity for simultaneous leg and torso animations. That would seem to make Mecanim Control useless for any game where characters are moving and attacking with a held weapon. So, virtually any RPG or FPS - which happen to be the exact two genres I need it for. Is this ever going to happen?
     
  4. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Well I never used the word promise. However I did try a few approaches, but unfortunately I could not find a solution that would fit the Mecanim Control 1.0.
    Mecanim Control 2.0 (available on the build) has an approach that could have the answer, but its functionalities are not yet available officially on Unity.
    I've spoken with the creator of Mecanim and he said that many of the libraries being used on MC2 will be available on Unity 5, but they still have to test and fix a few things over.

    I'm currently a little busy with some of the features on UFE, but after Unity 5 is officially released I'll try to finding some time on my schedule to revisit Mecanim Control 2.0. I can't promise an exact date, but its definitely on my list.
     
    schmosef and hopeful like this.
  5. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Thanks for finding that bug, and sorry for not being able to help when you needed. I'm glad you found the answer to your problem!
     
  6. Ceraph

    Ceraph

    Joined:
    May 16, 2013
    Posts:
    19
    Sorry to keep posting about bugs, but has anyone experienced issues with using Mecanim Control along with Unity's humanoid retargeting system?

    I've had an animation controller that's been working fine for a while now, but as soon as I changed my Default / Idle animation to use an animation that was retargeted from another skeleton it stopped playing sometimes. It doesn't happen all the time, but sometimes when I call PlayAnimation for "Idle" or "Default" it just doesn't play. The debug information says the current animation clip name is correct (either "Idle" or "Default"), but the animation itself never plays. Any information on how to solve this would be greatly appreciated.

    Thanks,
    ~ Ceraph
     
  7. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,471
    I don't know if you've had a look yet at the official release of U5, but there's already been word of a significant mecanim upgrade coming in 5.1.
     
  8. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Yes I'm already on it. Its my priority right after updating UFE 1.5
     
    hopeful likes this.
  9. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    Can you please add an option in the arrys for applyRootMotion ? so we can choose in each motion to apply root motion or not,

    Many thanks
     
  10. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Alrite guys, I got some good news

    I've just updated Mecanim Control 2.0 with the new features on Unity 5 and I'm glad to announce it works like a charm =)

    The hidden libraries are no longer hidden, and they fixed all there was to be fixed.

    I'll be reviewing the suggestions given and see what I can add before the next update. Stay tuned.

    Good idea. I'll see what I can do.
     
    hopeful likes this.
  11. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    845
  12. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,471
    When the next update comes around, it would be good to have some sort of a guide for this that points out the primary benefits of using this system. Can you ... save memory? Run more efficiently? Create faster? Do things easily that are hard to do otherwise? And are there any drawbacks or pitfalls to watch out for?
     
  13. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    My friend you will just drop humanoid animation clip into a list and set the name thats all, no more visual dependency! you see, unity screwed up my controller 3 times ! with more than 75 nodes! , just in the death layer i have 15 nodes ! you know what it means to link every node each time? man ! and now i a m making backups everytime i modify the controller, with this system is really easier, i am not using it because of the hidden libraries and so in the old version, but developer said in the last comment that unity fixed that and mecanim control will have all the benefits ! yahhoooo for that ! you will not lose your money !


    *** dear developer any ETA ?

    Many thanks
     
  14. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    So much for good news...
    So, as some of you know, the libraries used by Mecanim Control 2.0 are no longer hidden. They got moved to UnityEditor and are now very well documented (UnityEditor.Animations). Unfortunately this doesn't fix our problem: We still can't compile MC2 into a standalone.

    Over the past few days I spoke to Mecanim.Dev about the issue, but apparently this is not on their priority list and we shouldn't expect this to improve any time soon.
    Unknown to these facts, I've actually made some significant improvements to the tool over the past week and even submitted the changes to the Asset Store. Some of the improvements include suggestions from angelodelvecchio and Ceraph as well as several minor fixes and extra parameters to a few methods. Here is a screenshot:

    MecanimControlSS.jpg

    In the package I made MC2 the official build for Mecanim Control, however I'm already working on a new update to revert this.

    Because of this, unfortunately Mecanim Control will not be able to support Blend Trees or any advantages MC2 could have brought us. Hopefully the folks at Unity change up their mind, but until then, we will all have to stick with MC1.
     
    Last edited: Mar 17, 2015
  15. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    845
    Drat!

    What's their logic for putting the API into the UnityEditor namespace?
     
  16. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Honestly, I don't know either.

    According to them "(..) Its an editor only API. We can't create a StateMachine at runtime."

    I showed him a MC2 video example to disprove that statement, but his reply was, and I quote, "When I said runtime, I meant standalone".
     
    Last edited: Mar 18, 2015
  17. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,471
    Well that's rotten news. :(

    So what features and advantages does a non-2.0 MC give us? Mecanim has added some functionality over the last year, and I'm not sure where MC stands in relation to that.
     
  18. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    MMind ! many thanks for the great update !

    please how it works to load animation in other layers ? to use different masks? for gun aiming?

    Many thanks
     
  19. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Layers is also not possible with MC1 unfortunately. The logic behind MC1 doesn't allow for complex Animator Controller techniques.
     
  20. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    MC1 uses a process of "runtimeAnimatorController" replacement. Each time an animation is called, Mecanim Control selects the correlated AnimationData and redraws the Animator Controller with the previous and next animations to seamlessly create a blending technique.

    MC2 on the other hand dynamically creates an entire StateMachine with all the animations listed under the Mecanim Control component on startup. Because of how it is structured, blending is a lot smoother. It also allows for free navigation and debugging using the Animator Controller itself.
     
  21. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,471
    I appreciate your answer, but as I'm not a regular mecanim user I need a little additional clarity.

    Let's say I have a game with something like 400 animations in an animator state machine, and I have 10-30 characters running this animator at a time. That's very unwieldy (a big animator), and it probably takes up a fair amount of memory ... but I don't have to have a separate animation for each character, so by using mecanim I save memory over using legacy. Right?

    What MC does is it narrows the scope of animation to 3 animations at a time: previous, current, and next. It doesn't take less memory, because you have to have all the animations in memory anyway. And while it relieves the burden of working with a massive animator state machine, you lose the ability to work with layered animation ... which is a significant drawback. So instead of having a gun-shooting animation and a run animation that work together in layers, you need to have a gun-shooting, a running, and a gun-shooting-running animation. So the tradeoff is that I need more animations and I use more memory.

    If I'm understanding this correctly, unless there are other reasons to use MC, it looks like with no 2.0, the MC technique is really only useful for certain applications.
     
  22. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    I haven't made massive tests such as that one to tell you if using MC1 has less or more impact than using a regular State Machine, but as far as memory usage goes I don't think the process will make any significant impact.
    As far as my memory tests went (4 characters, 80+ animations each) MC1 showed 0 to no impact on the profiler.
    When talking about memory however, based on the data you mentioned, I'm sure MC1 would be the least of your problems.

    Except for the memory part, I agree with you. The state machine tradeoff is the selling point though, but the lack of layers can be a significant drawback.

    Mecanim Control is a sub product of Universal Fighting Engine, meaning its initial goal was to provide several much needed functionalities to Mecanim (as seen on this page). The product is useful for games that are not dependent on layers or blend trees, but still need to rely on Legacy functionalities. I've attempted blending trees and layers several times in the past (as seen on previous posts on this very topic), but none of them were truly effective using MC1.

    Thanks to the support received I did extend some of its methods, but there is just so much we can accomplish with the limitations given, and as we just saw, some limitations are just above us. What we can do now is wait and hope other high caliber developers join the cause and convince Unity.
     
  23. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I'm using the V1 (unzipped from sources) in U5. The sample is having

    transform.position assign attempt for 'Constructor' is not valid. Input position is { NaN, NaN, NaN }.

    Also, my own project I get 3 OnAnimationEnd callback instead of one (old behavior in 1.04)
     
  24. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Yeah I noticed this bug yesterday. Already sent an update to Unity. On the update I moved MC1 back as the official build and fixed that and a few other bugs with it. I'll let you guys know as soon as Unity approves it.
     
  25. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    PM u, can send me fixed build?
     
  26. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Mecanim Control 1.1 has been approved and its now available for download/update.

    Release Notes:
    - Fixed default animation bug
    - Play method extended
    - SetMirror method extended
    - Added "Apply Root Motion" for individual clips and a global "Override Root Motion" option
    - Demo script improvements (added more options)
    - Fixed problem where duplicated animation files would sometimes pick the wrong animation data.
    - Mecanim Control 2.0 also updated, however Unity 5 still doesn't support it. More information can be found on this post.
     
  27. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I get an error now, and the animation is still firing 3 times.

    NullReferenceException: Object reference not set to an instance of an object
    MecanimControl.GetCurrentClipPosition () (at Assets/External/MecanimControl/Scripts/MecanimControl.cs:420)
    MecanimControl._playAnimation (.AnimationData targetAnimationData, Single blendingTime, Single normalizedTime, Boolean mirror) (at Assets/External/MecanimControl/Scripts/MecanimControl.cs:283)
    MecanimControl.Play (UnityEngine.AnimationClip clip) (at Assets/External/MecanimControl/Scripts/MecanimControl.cs:254)
    TriggerAnimation.Awake () (at Assets/Script/TriggerAnimation.cs:19)
     
  28. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Humm, that is odd. Does this error happens at startup?
    Maybe there is no animation added to the animation list? Try placing an animation under the default animation slot, see if that does anything.
     
  29. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I got some time to look into this more.

    You are initializing on Start now. Previously I was calling Play on Awake, now I have to move to Start.

    In _PlayAnimation, calling GetCurrentClipPosition result in exception as currentAnimationData is null. You commented out quite a bunch of code check there. I think there null check is still need when I call Play at Start.

    Still, _PlayAnimation has error later as currentAnimationData is null. I have no more time to investigate further.
     
  30. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Don't worry, I'm not asking you to strip down the script to find the problem. I'm mostly interested on your animation setup so I can attempt to replicate the issue (with the provided templates) and give some pointers.

    Yes you are correct. The Start function is now being used to set the Default Animation.
    I also had to move the initial currentAnimationData setup to this method due to some issues with the Animator Controller. A hand full of models would throw unexpected console errors after calling the RuntimeAnimatorController on the Awake function. These errors had no correlation with MecanimControl (they would point to random untraceable Mesh errors) however after several weeks of tests I managed to pin-point the problem. You can try moving those functions back to the Awake function, but I can't guarantee you won't have the same problems.

    If you need the character to start the game with an animation, try setting the default animation first. As soon as the Start function is called your character will play that animation. If you don't setup a default animation, MecanimControl will assign the first animation on your animations.

    GetCurrentClipPosition() no longer return a 0 on null currentAnimationData because of how often it would lead to untraceable bugs.

    Actually some of that was already commented on previous versions. I left those algorithm commented so they can be studied and/or be used as alternatives, but they serve no real purpose. In fact thats the reason why they are commented =)
     
    Last edited: Apr 14, 2015
  31. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I'm using 1.04., it works fine even upgrading to U5. I will send u my setup later but there's nothing special, I think, I just have multiple Play instead of once.
     
  32. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
  33. kimsama

    kimsama

    Joined:
    Jan 2, 2009
    Posts:
    166
    Last edited: Apr 27, 2015
  34. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,471
  35. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    342
    Hi,

    I'm currently applying mocap data to a character in realtime and attempting to engineer a way to map this data onto different characters. I'm looking for a result similar to playing an animation clip across differetn avatars, bone retargeting etc. I'm experimenting with dynamically creating an animation clip from the data and then playing it via the animator controller. Not having much luck at the moment and curious to your tool.

    Do you think I could get this working with Mecanim-Control? The clip would have to be continually adding new keyframes as the mocap data is streamed.

    Thanks!
     
  36. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Mecanim Control is basically a replacement for the State Machine system from Mecanim. It allows you to control animations and events the same way you would with legacy.
    Mecanim Control allows dynamic adding and removing clips, but I'm not entirely sure how it would work with an animation that is being created at runtime with mocap. Depending on how you are setting this system up, MC might be useful. For a full list of functionalities take a look at this link.
     
  37. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,471
    Apparently there's a new Playables API coming to mecanim in 5.2 (due Sept 8). Not sure if it helps / affects anything here, but thought I'd mention it.
     
    schmosef and Mistermind like this.
  38. Kecske85

    Kecske85

    Joined:
    Apr 19, 2013
    Posts:
    8
    So 5.2.1 came out and broke the animations again. You can check in the demo scene, when a new animation is started, the guy jumps to a weird pose for the first frame. MMind can you take a look? Maybe it can be fixed, though I suspect a bugreport will have to be filed. Time to revert once again -.-
     
  39. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    5.2 is very buggy right now. I was able to catch a few bugs, but there are a lot of problems with this version. I even decided to skip UFE updates til 5.3.

    I'll keep you guys updated on any development.
     
    hopeful likes this.
  40. cranecam

    cranecam

    Joined:
    Nov 25, 2013
    Posts:
    24
    hi,
    is your current version working well with 5.2.3 ?
     
  41. Kalle801

    Kalle801

    Joined:
    Mar 3, 2013
    Posts:
    80
    Hello.
    Im new to unity and Animations are the hardest part for me.

    I just use "Idle" & "Run". I added the controller to my player but how does the system know: Press nothing = Idle and Press "w" = Walk?

    I dont know :( Please help.
     
  42. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    845
    Hello @Kalle801,

    The Unity Learn site is your friend. If you are new to Unity, start there.

    There is a section of the Learn site dedicated to Animation.

    Lots of great mecanim tutorials on YouTube as well.

    Since you are a beginner: for a good overview of Mecanim, check out this video from Unite 12.
     
    Mistermind and theANMATOR2b like this.
  43. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Hi @MMind , I am trying to achieve some specific runtime animation functionality and this asset looks like it could do that. I basically have a number of mecanim states, each state has an attack animation. The player has controls such as left punch, right punch, left kick and right kick. I would like the player to be able to choose their attack animations for each of these, eg. left punch could be a jab or back fist or uppercut etc. This is quite similar to the common "Create a fighter" feature in many beat em up games. Therefore I would need a way to change the animation clips at runtime via a UI.

    I have looked through the documentation and can see functions for getting an animation clip, but no way to change an existing clip to a different one. Is this possible with this asset or have I misunderstood?
     
  44. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    483
    I see this has gone free this week, but I suppose that's because it's more or less deprecated and won't work in newer Unity versions. Correct me if I'm wrong.
     
  45. Mistermind

    Mistermind

    Joined:
    Jun 8, 2013
    Posts:
    758
    Don't worry, it still works as intended. I just decided to give the tool for free for a little while =)
     
    schmosef and theANMATOR2b like this.
  46. AGregori

    AGregori

    Joined:
    Dec 11, 2014
    Posts:
    483
    Well, on the store it's listed both as 1.1 and 2.0, and all the reviews are from 2014 or so, so I figured it's an unmaintained goner. But it's good if it's still on.
     
  47. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Never mind, this fixed my problem!! :D

    Edit: Just stumbled across something weird.

    Every time fill in the normalizedTime (such as 0.0f) it throws an error instantly.
     
    Last edited: Mar 28, 2018
  48. softrare

    softrare

    Joined:
    Jun 12, 2011
    Posts:
    444
    Are there news about MC2 and/or animation layers? This would be SO awesome with layers.........
     
  49. chris_unity227

    chris_unity227

    Joined:
    Feb 10, 2020
    Posts:
    1
    Hi all - doesn't seem to work with Unity 2018.3 update. Apparently all "root motion" enabled doesn't work and my animations aren't allowing movement anymore. this worked fine on 2018.2
     
unityunity