Search Unity

Mechanim = pain

Discussion in 'Animation' started by DDNA, Aug 2, 2016.

  1. Ideka

    Ideka

    Joined:
    Feb 23, 2015
    Posts:
    9
    So wait, does that mean I can set a new temporary override controller, then change a clip on the original override controller, and then set it back and delete the temporary one without the machine resetting? If so, er, how? Can you provide a code example?
     
    mr_blahblah likes this.
  2. DDNA

    DDNA

    Joined:
    Oct 15, 2013
    Posts:
    116
    There was a time that I tried making a controller that was just 2 states A and B. Then managing everything else in code with an override controller. In this way I could just use MechAnim's blend but manage all the states myself by just setting clips at runtime, and not having to deal with all the state naming etc. i.e. load a new clip in B and trigger a crossfade.

    All the problems with the override controller made this not work at all but in 5.5 I may try this again, because it would give me a single reusable procedural controller which is what I have been looking for the whole time. I spent some time looking at way the legacy controller worked, but the way the weights work is wacky, and unnecessarily cumbersome.

    I wish it was possible to just make a new animation system. Like an API to just set the bone positions. I guess unity would have to be better about importing and processing new data types. If it was some people might come up with some great solutions in the Asset Store.
     
  3. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,663
    You can create your own animation system if you wish, everything is there. Mecanim was first implemented as an external component.
     
  4. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,663
    @DDNA I have a fix for your bug 828199, it on his way to 5.4, I will let you know when it land in 5.4

    The bug was trigggered by blending two additive animation clip but one of them didn't have any scale animation curve for the hips and in this case mecanim was faulty adding the default value which is 1.

    So I have a question, why do you have so many scale animation curve over all your rig if all of them are always at the default value? Normally when you import a file with default setting, keyframe reduction ON, all thoses curve should disappear and you will save a lot of cpu cycle.
    You can also strip them in your authoring tools if you prefer.
     
    theANMATOR2b likes this.
  5. Ideka

    Ideka

    Joined:
    Feb 23, 2015
    Posts:
    9
    @Mecanim-Dev sorry to be insistent, but can I get an answer to this?

     
  6. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,663
    @Ideka of course I can, sorry.

    So as mentionned in the doc
    http://docs.unity3d.com/ScriptReference/AnimatorOverrideController.html

    Swapping Animator.runtimeAnimatorController with an AnimatorOverrideController based on the same AnimatorController at runtime doesn't reset state machine's current state.

    So the twist is to have the same AnimatorController for both AnimatorOverrideController.
    Code (CSharp):
    1.    
    2. public class OverrideClip : MonoBehaviour
    3. {
    4.     public AnimatorOverrideController overrideController;
    5.     protected Animator animator;
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.         animator = GetComponent<Animator>();
    10.     }
    11.    
    12.     public void Set (string name, AnimationClip overrideClip)
    13.     {
    14.         AnimatorOverrideController newOverrideController = new AnimatorOverrideController();
    15.         newOverrideController.runtimeAnimatorController = overrideController.runtimeAnimatorController;
    16.         newOverrideController[name] = overrideClip;
    17.  
    18.         animator.runtimeAnimatorController = newOverrideController;
    19.         // Destroy only if you're override controller is not an asset
    20.         Destroy(overrideController);
    21.  
    22.         overrideController = newOverrideController;
    23.     }
    24. }
    25.  
     
  7. Ideka

    Ideka

    Joined:
    Feb 23, 2015
    Posts:
    9
    @Mecanim-Dev

    OK, so considering that, I thought I'd get smart and create a second AnimatorOverrideController in Awake like so:
    Code (csharp):
    1. this.StandbyAOC = new AnimatorOverrideController();
    2. this.StandbyAOC.runtimeAnimatorController = (this.Animator.runtimeAnimatorController as AnimatorOverrideController).runtimeAnimatorController;
    And then, when I need to change a clip:

    Code (csharp):
    1. this.StandbyAOC[theStateName] = theClip;
    2. AnimatorOverrideController temp = this.Animator.runtimeAnimatorController as AnimatorOverrideController;
    3. this.Animator.runtimeAnimatorController = this.StandbyAOC;
    4. this.StandbyAOC = temp;
    but this resets the state machine still (Unity 5.4.0f3). Any ideas?
     
  8. DDNA

    DDNA

    Joined:
    Oct 15, 2013
    Posts:
    116
    >I have a fix for your bug 828199, it on his way to 5.4, I will let you know when it land in 5.4

    Great! Thank you very much. I just updated the project to 5.4.1 FWIW

    >So I have a question, why do you have so many scale animation curve over all your rig if all of them are always at the

    You have to understand this there has been a lot of frustration getting predictable results out of Unity. So the scale keys are a product of the export process/baking I believe. We have had odd things happen when we have left channels without data in unity so as a standard practice we key every channel and bake it out before coming into Unity.

    We have turned off the key compression on everything for the same reason. The problems with that started with animations that didn't quite end up where we wanted them. Like looking down the sites of a gun being off. Also we had an issue with re-sample changing the tangents on curves improperly. That in combinations with when we started having the more serious problems (described in this thread) we just turned off compression and resampling on everything to eliminate possible problems. I figured at some point if this becomes a performance bottleneck I could turn them back on. But in out previous project this never became an issue. I would love to optimize the game objects as well, and possibly switch tot he human rig.

    Now that we have this working a little better maybe I will look at turning the compression settings back on. Is there a setting that will just remove redundant keyframes only. So the animations don't actually change at all? Would this just be Keyframe Reduction is 0 Error? What does optimal do?
     
  9. DDNA

    DDNA

    Joined:
    Oct 15, 2013
    Posts:
    116
    Is there a way to set the bone positions directly? versus making all the bones gameobjects? Are the Update methods the right place to update them?

    Our previous engine was in XNA, which had an excellent and extensible content pipeline. It was easy to make the system recognize a new file type to import. Or to take an existing file type and process the data in a different way for your purposes. They called this Importers and Processors. An Importer read the data into an intermediate format and a processors do data from one intermediate format and processed it into another. I haven't found a way to do this with unity at all which is really a barrier to extending the functionality of the engine. Maybe I am just not aware of this. But if I wanted to import an FBX file and process the animation into my own format for runtime is this something I could do?
     
  10. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,393
    You can hook into the processing pipeline through AssetPostorocessors, but the docs are kinda bad and very old, so you'll have to experiment.

    I also don't believe you can make Unity import the object into a different, custom format. So you can't create your own fbx-importer format and make Unity serialize the fbx into that.
     
  11. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,663
    Have you try to upgrade to 5.4.0p4?
    I did fix something related to this.
    Animation: Deleting or changing an Override controller that was previously set as the runtimecontroller no longer reset the animator statemachine memory.

    If after the upgrade you still see the same bug, please log a bug and I will take a look.
     
  12. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,663
    Yeah you hitted a few nasty bug. So as a best pratice for performance reason we recommend to user to remove the scale curve if they don't animate them.
    http://docs.unity3d.com/Manual/MecanimPeformanceandOptimization.html
    As a first test you could renable keyframe reduction, and set both position and rotation error to 0 to disable keyframe reduction on thoses curve and put a small value for scale.
    The best solution would be to completly remove them if they are never animated.

    The optimal settings try to choose the best internal representation to reduce memory size. Mecanim support two kind of animation curve: streamed and dense.
    A dense curve is a resample curve with a linear interpolation between key. A key is simply a value
    A streamed curve is a curve optimized to reduce cache miss with all the coeffience pre baked. It take more memory to store a key(time, 4 coeff) but for curve that are not resample and sparse the end result is less memory and better perf.
     
  13. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,663
    @DDNA Bug 828199 has been fixed and landed in 5.4.1p1 today.

    5.4.1p1 is expected to be release next week
     
  14. Ideka

    Ideka

    Joined:
    Feb 23, 2015
    Posts:
    9
    Alright, so I tried 5.4.0p4, the animator isn't reset anymore, but if I change a clip during a state transition, the goal animation gets frozen and doesn't play (the bar still fills up as normal in the animator window though).

    As a "fix," I made the following class:
    Code (csharp):
    1. using System;
    2. using UnityEngine;
    3.  
    4. public class PreserveAnimator : IDisposable
    5. {
    6.    private Animator animator;
    7.    private AnimatorStateInfo[] layerInfo;
    8.  
    9.    public PreserveAnimator(Animator animator)
    10.    {
    11.       this.animator = animator;
    12.  
    13.       this.layerInfo = new AnimatorStateInfo[this.animator.layerCount];
    14.       for (int i = 0; i < this.animator.layerCount; i++)
    15.           this.layerInfo[i] = this.animator.GetCurrentAnimatorStateInfo(i);
    16.       this.animator.Update(0);
    17.    }
    18.  
    19.    public void Dispose()
    20.    {
    21.       this.animator.Update(0);
    22.       for (int i = 0; i < this.animator.layerCount; i++)
    23.           this.animator.Play(this.layerInfo[i].fullPathHash, i, this.layerInfo[i].normalizedTime);
    24.       this.animator.Update(0);
    25.    }
    26. }
    And then use it like so:
    Code (csharp):
    1. using (new PreserveAnimator(this.Animator))
    2. {
    3.     this.StandbyAOC[theStateName] = theClip;
    4.     AnimatorOverrideController temp = this.Animator.runtimeAnimatorController as AnimatorOverrideController;
    5.     this.Animator.runtimeAnimatorController = this.StandbyAOC;
    6.     this.StandbyAOC = temp;
    7. }
    This introduces a new problem or two, but I might be able to work around them for now...
     
  15. hakankaraduman

    hakankaraduman

    Joined:
    Aug 27, 2012
    Posts:
    336
    I read the conversation and looked at the links shared.

    ----
    Simple Animation
    Playing a single Animation Clip with no blending can make Mecanim slower than the legacy animation system. The old system is very direct, sampling the curve and directly writing into the transform. Mecanim has temporary buffers it uses for blending, and there is additional copying of the sampled curve and other data. The Mecanim layout is optimized for animation blending and more complex setups.
    ----

    Regarding this paragraph from the manual, I don't use blend trees in my project. Only states and transitions between them? Is it better for me performance wise to use legacy animation system?

    I extensively use animation clip event calls , does legacy animation system support that?
     
  16. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,663
    Yes it does.

    This comment is for simple case when you have a controller with only one clip.
    Do you have any performance issue?
     
  17. hakankaraduman

    hakankaraduman

    Joined:
    Aug 27, 2012
    Posts:
    336
    Sorry I asked without profiling, now I profiled my game and actually animation is the least consuming part. It's very good
     
  18. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    287
    This is definitely not a design choice we made. It's a side effect of 1- Unity selection is global (this will change at some point in the future, but it's a bit outside of the Animation team's purview), 2- Selecting assets in Unity always highlights the asset in the project browser, and everything in the AnimatorController is a hidden sub-asset of the Controller. So the controller gets selected all the time.

    I'm currently implementing a fix for that: Project Browser will not center the view anymore if the selected asset(s) are hidden. It's might be too late for 5.5 (I'll check if it can be backported), but it should be available in a 5.6 alpha/beta soon.
     
    dreasgrech and Noisecrime like this.
  19. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,290
    If you ever will remove the legacy, please make sure no project breaks.
    so this means auto updating all the animations to mechanim.
    And no user action is required at all.

    Otherwise I guaranteed will loose my patience in the process to update all the deprecated animations I have ever bought or used.
     
  20. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,212
    I actually disagree with that. We have projects that depend almost entirely on legacy animation, but even then I don't want this to prevent Unity from evolving. I say out with the old and in with the new. The sooner the transition is made, the better.

    Anyway, recreating the Animation component with the PlayablesAPI would be a piece of cake
     
  21. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,290
    What is so wrong about auto updating to the new API? and saving users time?

    This would mean the old is out. you can have your cake and eat it too.
     
  22. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,212
    It takes unnecessary dev time to accomplish this. They could make better use of this time
     
  23. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,290
    Here I would disagee :) One dev time's day can save 100.000 user days in this case.
     
  24. DDNA

    DDNA

    Joined:
    Oct 15, 2013
    Posts:
    116
    So here I am several months later, still trying to get a guy walking around holding a gun. I have made some progress but still left with some really non-optimal solutions. So I have this complex state machine for handling a gun on my player, there is a lot of these and I can't switch out the animations at run-time so I am left with copy and pasting this huge state machine over and over and setting the new motion clips on each one. Because each of these has like 50 animations (times like 50 guns, you get the ides) and dragging and dropping these is time consuming and prone to error, and would be catastrophic if we needed to change the graph for some reason.

    What we have decided to do is build an editor script to help with this process. First we tried writing a script that built the graphs from scratch. This was met with many problems one of which is there doesn't seem to be a way to create a blendtree in a substate machine, or move a state to a substate machine for that matter.

    https://forum.unity3d.com/threads/creating-a-blendtree-in-a-substatemachine-via-api.461391/

    In fact creating blend trees at all in the API seems to make really weird stuff happen. Like you end up with things like a blend tree in the root of the layer and one in a state that are linked together. Or a list of every blendtree appearing under the controller in the project view. Based on MechAnim dubious stability and habit of corrupting the controller this sort of thing really worries me.

    So I though how about I copy and paste the SubState Machines myself, than run a tool over it to just change the motions.

    These states are very complex with nested levels of Blendtrees etc. We are also using Synced layers. So my first disappointment was that when I copy and paste the states the inner information like the complicated multilevel blend trees are not copied on the synced layer. So not if I was going to go this route I have to hand recreate the all the blend trees for ever gun I add to the state machine. I found that if you do the copy and paste on the synced layer instead it seems to do what I need but exposes this bizarre bug.

    https://forum.unity3d.com/threads/mechanim-changing-one-state-changes-another.461447/

    Unfortunately I found out that sometime previous in creating this complicated controller I mush have done this because there are a bunch of these states that are not eternally linked together and I don't know how to correct this.

    I think the first answer here is going to be "Use the Override controller" which I am very familiar with. It was actually my initial approach to my problem. First of all I am already using an Override controller for different versions of my player. But when I did this some time ago, bad things would happen when I changed these at run-time. i.e. the animations on all the other layers would get reset.

    What I am doing doesn't seem like a far out use for an animation system, so I must be doing something wrong. Maybe someone has some advice for me.
     
  25. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,212
    @DDNA
    The only real solution to what you're trying to accomplish is coming in Unity 2017.1 in the form of the Playables API, which basically gives you complete control over animation. I think any other approach would require too much manual work and/or would be unmaintainable

    Or, if you can afford to build your animation system without avatarMasks temporarily, you can even do it right now in the 5.6 beta (masks are the only major thing missing at the moment, I think)

    Temporary documentation here: https://forum.unity3d.com/threads/animationclipplayable.451854/
     
    Last edited: Mar 17, 2017
  26. mr_blahblah

    mr_blahblah

    Joined:
    Jan 15, 2016
    Posts:
    25
    Adding an expression of my pain. We have a turn-based system that is basically deterministic, but features a lot of animations. We experimented with mecanim's substates and animation compelteion events, and found it really unreliable.

    Not to mention the interface - there's so, so much missing from Mecanim, it's not even funny any more. We had to write so much proprietary code just to get animations to work, detect completion, manage states.... Mecanim needs an overhaul.

    There seems to be a massive level of denial/cognitive dissonance happening on the Unity/mecanim dev side of things. Someone needs to assign significant resources to fix it, make it easier to use, and bring it up to commercial standard.

    As it stands, I would not recommend Unity to a fellow developer - and that's mostly based on Mecanim's shortcomings. If you're doing anything with animation, avoid Unity and Mecanim, is what I tell people.
     
    ZenTeapot and LiberLogic969 like this.
  27. DDNA

    DDNA

    Joined:
    Oct 15, 2013
    Posts:
    116
    lol at least I am not the only one.

    It looks like they fixed the problem where the Animation Controllers Reset, so I am going to back to trying it that way. At least I will only have one state graph and not have to worry about all this copy paste errors.
     
  28. mr_blahblah

    mr_blahblah

    Joined:
    Jan 15, 2016
    Posts:
    25
    *bump*

    Vastly disappointed to see 5.6 launch with no significant mecanim improvements (ctrl-f 'mecanim' = no results).

    There's a bunch of animation changes/fixes a mile long - which is great - but I can't help but think Unity is intentionally overlooking a deep sea of broken/unintuitive/poorly supported animator features. Seriously, what gives? It really sucks - I prefer Unity to Unreal for a stack of reasons - but I can't touch it until I'm confident mecanim/animator controller/state machine behaviours etc are actually working well and the interface is vastly improved.
     
  29. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,663
    We don't use anymore the mecanim tags in release note since 5.0 I think.
    it all under Animation

    There is nothing we can do to help you if we don't know what is broken. You seem to have a long list of thing not working, we would be happy to fix them if you let us know what is not working.

    @DDNA has been pretty vocal on physic integration with animation, guess what, we are actively working on a solution that will bring physic and animation to another level
     
  30. DDNA

    DDNA

    Joined:
    Oct 15, 2013
    Posts:
    116
    >has been pretty vocal on physic integration with animation,

    That is really great!! Thank you.

    btw I tried 5.6 and additive animation seems to be completely broke. Our character goes into a contorted pose or just ignores the animations completely. It is easy to reproduce in our huge project but I wasn't able to reproduce this in a smaller project. We are close to shipping so I needed to roll back to 5.5
     
  31. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,212
    Then the bug is probably a version-upgrade bug. There was a note that clearly said upgrading from 5.5 to 5.6 could break animations in the release notes of 5.6
     
  32. DDNA

    DDNA

    Joined:
    Oct 15, 2013
    Posts:
    116
    What note are you referring to specifically?
     
  33. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    UT is in denial that Mecanim does not meet the expected success and tries to impose it, even to sacrifice Legacy.
    I would like to know once and for all when the old API will be obliterated. In 2018,2019 ..
     
    ZenTeapot likes this.
  34. ZenTeapot

    ZenTeapot

    Joined:
    Oct 19, 2014
    Posts:
    10
    When will I be able to get a list of AnimationStates at runtime? I'm not talking about using UnityEditor.Animations.AnimationController, which doesn't link for generated executables. This is EXTREMELY FRUSTRATING. It just seems really weird not being able to do something simple as that. Animator should already have this information. Why is it not exposed?

    It could also be DOUBLE GOOD that allowing behaviors to be added dynamically, at runtime. It's a simple event system that should have dynamic support. Manually click-drag-bind a statemachinebehavior script that does simple event forwarding to a bunch of animation states just seems silly, repetitive and prone-to-error.

    Is there possibility releasing the source code of the animation system? At least I'll be able to partially re-do it for much easier usage with simple sprite animations.

    It pains me so much whenever I come about working with the animation system. The extra complications working with simple animations, the undocumented intricacies that Play/CrossFade on same state starts with the previous normalizedTime not default 0.0f. The obvious and unfathomable unable-to-dos like getting list of animation states. The anti-human UX with the animation editor. What have you done in name of the optimization and abstraction? To be honest the whole mecanim system seems amatuerish, that a college graduate did according to his wishful thinking of how animations are done.
     
    Last edited: Apr 9, 2017
  35. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    892
    Mecanim is horrible to work with on a large project, can we at least have scripting option/control instead of this visual tool?
     
  36. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,212
    Playables API.
    It's the answer to every single complaint in this thread. I've started using it on my project and I could never go back to visual editors like mecanim now
     
  37. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    892
    have you tried this?
    Code (CSharp):
    1.  
    2.     AnimatorControllerParameter param;
    3.  
    4.       for (int i = 0; i < anim.parameters.Length; i++)
    5.         {
    6.             param = anim.parameters[i];
    7.             if (param.type == AnimatorControllerParameterType.Bool)
    8.             {
    9.                 print(param.name);
    10.             }
    11.         }
     
  38. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    892
    maybe i check it out. this in a Experimental state atm and might be removed it says.
     
  39. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,393
    Hey, you just allocated (anim.parameteres.length + 1) arrays! Yes, of course you get punished by GC for getting the parameter names, why wouldn't you? You also found the parameter name instead of the states, which doesn't help much, but it's something.

    Playables is looking real nice. I'd still want to have a system where our animator can preview and edit animation transitions, though, so something has to be built on top of it. That's an effort that the community probably should open-source at some point.
     
    theANMATOR2b likes this.
  40. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    892
    Not sure if your trolling or not. But param is allocated on the stack on Awake state (i just put it there as an example, same goes for print.) If we going in to stupid crafting theory, the print would generated more allocation than the i array.
    anim.parameters.Length is just for the lenght(its a int). I use this code for all my animation and i see no GC or memory allocated , so you either dont understand the code or is just trolling. Bools are states, they will show the name of the animation state. you can select any param you prefer. Its preferred to use your own statemachine anyways.

    I don't think this thread is about allocation...but i he happy to discuss allocation in another thread with you.
     
    Last edited: Apr 10, 2017
  41. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,393
    Not trolling. Yes, you can cache the parameters array on Awake. Sure.
    Still, it's yet another gotcha in the system that's easy to miss. You don't expect that calling anim.parameters is an allocating call, but since it's fetching data from the c++ side, it has to allocate the array in C# land.

    You're still missing the point that parameters are not states. ZenTeapot asked for "When will I be able to get a list of AnimationStates at runtime?". I'm pretty sure "AnimationStates" refers to the animations (ie nodes) in the animator controller, not the bool parameters. If you want to be pedantic, the type is AnimatorState, but that's splitting hairs.
     
  42. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    892
    You always cache your allocation, i don't really see your point here, allocation has to happen at some point, nor a problem. I was just showing an example how you get the bool states that is connecting the nodes. If an animation is running, its in a bool true state. Maybe people do it differently i don't know.. I like to keep my animation bug free including my memory.. bools are also int and take less allocation than text arrays.. like anim.Play("stringArray"); Instead i use anim.SetBool(Anis,true); the whole purpose of my code is to have zero allocation in the game while running, triggering animation with text array generates a mess of allocation, nor does it give full control of what is going on.

    I didn't post the whole code i use, but i add this params in to a generic type List that i use for animation that uses Enums.
     
    Last edited: Apr 10, 2017
  43. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,212
    A year ago, the future of the Playables API was very uncertain, but I heard a dev say last month that it was scheduled to move out of experimental and see a full release for Unity 2017.1 this summer. I'd say it's pretty safe to use. We might even get the beta in the coming weeks

    I assure you; Playables API is the key to proper animation handling in Unity. It's one of the greatest additions Unity has ever made to the engine. You no longer need to have your gameplay logic and animation states be two separate parallel things that just hope they're still properly in sync. Now both can be handled together in the same script. Your animation state can be a class that you make yourself, and you always have access to it

    Here are some examples: https://forum.unity3d.com/threads/animationclipplayable.451854/
     
    Last edited: Apr 10, 2017
    mikael_juhala likes this.
  44. DDNA

    DDNA

    Joined:
    Oct 15, 2013
    Posts:
    116
    It sounds like the right approach. If I choose to make another game with Unity I will have to take a look at it.
     
  45. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,212
  46. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,663
    We are working on extending the playable with the new Compute jobs that joachim did demo at GDC this year.

    The goal is to allow user to write c# playable that will be invoked and blended by the animation system.

    Take a look at this 3 script
    TwoBoneIKSample.cs -> setup the playable graph, simple graph with a clip connected to the TwoboneIK playable.
    TwoBoneIKJob.cs -> the playable
    TwoBoneIK.cs -> an helper function for a two bone ik.

    You can't do anything yet with those script as you need the developpement branch which is not available at the moment, but this give you an overview of what we are working on.

    I'm implementing a physic playable with this new system which will allow you to blend physic and animation togheter without having to deal with all the twist necessary to make it work with the old system
     

    Attached Files:

    theANMATOR2b and JosephHK like this.
  47. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,212
    Beautiful!
     
  48. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    892
    I like the sound of that
     
  49. ZenTeapot

    ZenTeapot

    Joined:
    Oct 19, 2014
    Posts:
    10
    I do mean the state names in Animator, as the Baste said. It's impossible to get a list of the states, despite much trying, unless you hardcode it or use a codegen. As ridiculous as it sounds it's not doable at the moment.
     
  50. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    892
    My question is, why do you want that? Mechnaim has its bool state system. You can either check state with IsPlayig("name" or bool check like i posted. Each state node in the Animator should have a paramater, you can then collect all the names this way, in the code i posted.