Mecanim runtime animation

Hi, if the mecanim animtion system supports runtime change animationclip in unity4?

for exsample, i have two animator states, StateA is normal animations, it has a blendtree that holds animationclips like idle, walk, run. and StateB has only one animationclip like attack(which in Motion or maybe in blendtree – only one animation node), at runtime, i want to change the animation in StateB.

i have search the whole scripts api, and find nothing(the interfaces are all read only).

thanks very much.

I want to know this too…
Mecanim is good, but if Unity marks old animation “lagacy”, macanim should be able to do everything the old animation system could.

You cannot change clip at runtime for now. This is something we want to add in a future release.

The old animation system won’t be remove before Mecanim can handle everything it was handling.

thanks. Waiting for this future~~~~

can i replace a animator controller achieve this ?

It has been more than a year since you posted your message and I wanted to know if this feature will be available in a near future.

Thanks

It should be available in the next point release 4.3

Can we now add and remove motion clips with the new 4.3 at runtime? I’ve been looking through the API and can’t see anyway to achieve this. Such a basic thing missing from mecanim yet required for customisation systems.

yes you can, you must use the AnimatorOverrideController component.

you can create your AnimatorOverrideController in the editor or at runtime.

Hi, this is the closest thing to documentation I have found so far about AnimatorOverrideController (very bad, Unity guys!). Could you please add some extra lines of code about how to actually using it to change the “motion” property of an AnimatorController state? I coulnd’t figure out how to do it!

Thank you very much in advance!

Sorry I think I misunderstood your question. You cannot add or remove clip at runtime, but you can override clips with AnimatorOverrideController.
By example if you have a controller with a clip ‘run’ you could override the clip ‘run’ like this.

RuntimeAnimatorController myController = animator.runtimeAnimatorController;
AnimatorOverrideController myOverrideController = new AnimatorOverrideController();
myOverrideController.runtimeAnimatorController = myController;

myOverrideController[“run”] = myRunFasterClip;

// Put this line at the end because when you assign a controller on an Animator, unity rebind all the animated properties
animator.runtimeAnimatorController = myOverrideController;

4 Likes

Hello guys.
The point is to be able to add and remove clips at runtime. We can’t make a system generic enough if mecanim can’t do this, and to be honest while its great, that “non-generic enough” is the reason I guess about 80% of people still use infamous so called “Legacy”

I’d really like to use mecanim. I do, but I can’t

1 Like

Sorry for reviving this post but this the only one I found that got close to a solution.

So in theory, to achieve the idea of adding and removing clips we first must create a dummy Animator controller and add the number of clips that could potentially be used as “slots”?

I’ve been trying to get around that idea any way I can, as its a bit counter intuitive for my end user.

The request for my toolkit to allow for Mecanim is enormous. I had to answer “why legacy” so many times I even made a review of Mecanim back on Unity 4.2.
After the promises on version 4.3 I was really hoping I could switch to Mecanim. There has to be a work around to be able to add clips without working with the visual editor.

There we go guys, this should help all of us:
http://forum.unity3d.com/threads/224315-Mecanim-Control

Let me know what you guys think and if the suggested price is fair.

1 Like

This example would be great to have in the Unity Documention

1 Like