Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

New Mecanim API functions: play animator clips directly?

Discussion in 'Unity 5 Pre-order Beta' started by Silly_Rollo, Nov 5, 2014.

  1. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    I was looking through the new API options but I didn't see anything like this, is there a way to just play a Humanoid clip on an Animator without having to position it within a state? Alternatively is there a way to swap out a clip in a state with another Humanoid clip?
     
    CWolf likes this.
  2. CWolf

    CWolf

    Joined:
    Oct 24, 2011
    Posts:
    106
    I'd be interested in anything like this with Unity 5 and any new Mecanim API hooks.
     
  3. WendelinReich

    WendelinReich

    Joined:
    Dec 22, 2011
    Posts:
    228
    Animator.Play() ? It's not in the new API because it was introduced 4.3, I think.

    In the editor, yes, you have the new Asset Creation API. I dont think there's any way to edit an animator at runtime, but you can replace the entire animator at runtime (via runtimeAnimatorController) with an AnimatorOverrideController in which you changed that one single state (though the AOC must have been prepared in the editor).
     
  4. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Animator.Play is for playing something within an existing AnimatiorController already setup I was referring to just playing a clip straight up like in legacy. Which I actually had to replace all my Crossfade calls wiith Play temporarily as Crossfade still crashes U5 b11.

    It looks like there isn't anything new beyond using AnimatorOverrideController. I have some hacky code for swapping out a "Replacer" state with the new clips as needed but I was hoping for something closer to legacy.
     
  5. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    Really, I think Unity needs an equivalent of the legacy 'Animation' component that can work with Mecanim-compatible clips and retargeting - with the full and direct code control that the Animation component provides.

    Mecanim is great in some cases (complex humanoid main characters), but in simpler cases, you don't want the extra hassle of creating an Animation Controller - you just want to play a couple of animation clips. And you want direct control - for example, setting an animation to a specific position instantly - rather than asking it politely to transition to a state... Mecanim still feels very indirect - it's in control, not your scripts.
     
  6. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Well that's Unity for you. Their particle system is the same way where you either have to mess with it via gui or with half assed code access. You'd think sometime in the last couple of years it would make sense to add to mecanim a PlayClip function as there are plenty of times a state machine is more bother than its worth and if we had source access someone would have added it immediately but so it goes.