- Home /
mixing animations
I want to mix to different animations together but I don't get it to work. My Blender made character shall change a little during a spezial game state. So I added a keyframe, that only scales the head bone a little so the head of the character appears bigger. Then I still want to use all other animations with the character (like walking) just with the bigger head. so i put this (BigHead) Animation to a higher Layer (10) and enabled it. But I didn't see anything change. Then I tried the AddMixingTransform function which didn't work either. Can anyone tell me how to achive that? can it be a problem, that i used LocRotScale Keys for all Bones on all the other animations?
Here are some Code Snipsets:
void Start () {
boxBehaviour = gameObject.GetComponent<BoxBehaviour> ();
rowdyBoxHead = animation["rowdy_box_layer"];
//rowdyBoxHead.play();
animation["rowdy_box_layer"].wrapMode = WrapMode.ClampForever;
//rowdyBoxHead.layer = 10;
//rowdyBoxHead.wrapMode = WrapMode.ClampForever;
rowdyBoxHeadTransform = transform.Find("Armature/Root/Root_001/Root_002");
StartCoroutine(ActivateRowdyMode());
}
IEnumerator ActivateRowdyMode(){
yield return new WaitForSeconds(60);
//rowdyBoxHead.enabled = true;
//rowdyBoxHead.weight = 1.0f;
animation["rowdy_box_layer"].AddMixingTransform(rowdyBoxHeadTransform);
// animation.CrossFade("rowdy_box_layer");
}
Usually you add mixing transforms at the start
If you want animations to player, you have to un-comment the
Play
callThat is also not how you play animations
Look at the documentation
The mixing Transform shall Start after 60 seconds?
I know, there where two different ways I tried in the documentation and I tried both here - so some are commented out. What I postet ist the last try of course it doesn't work. It shows just what I tried
What do you mean? I got a lot of animations to play. But the documentation said, if I layer animation, I do not use .Play() I just enable them - did not work, or at least I didn't see anything second Way was to use animation $$anonymous$$ixing - therefore I used .Play () - now commented out - didn't work either. So I tried to combine things and ended up with the mess you see currently.
I did und I did it exactly as it was written there (even so you don't see it anymore)
As paraphraised from a person whose name I've forgotten:
"Sometimes you just have to select the entire contents of a function and press delete"
I know how horrible that sounds, but once something turns into a mess, its easier to start from a clean slate, than trying to clean it up.
The way you usually do it (with legacy animations) is you set the layer (and the mixing transform) in Start
(as well as any other animation settings), then you use animation.Play(name:String)
to play the animation.
That's how I would do it, and that's how I've done it in the past :)
I have the following now:
void Start () {
animation["rowdy_box_layer"].wrap$$anonymous$$ode = Wrap$$anonymous$$ode.ClampForever;
rowdyBoxHeadTransform = transform.Find("Armature/Root/Root_001/Root_002");
animation["rowdy_box_layer"].Add$$anonymous$$ixingTransform(rowdyBoxHeadTransform);
StartCoroutine(ActivateRowdy$$anonymous$$ode());
}
IEnumerator ActivateRowdy$$anonymous$$ode(){
yield return new WaitForSeconds(5);
animation.CrossFade("rowdy_box_layer");
}
The Head scales up, but the underlying idle animation seems to be suppressed. After a while, the walk animation starts and after that the head rescales back to its normal size. I do not see, that both animations work together. But I belive that $$anonymous$$ixing is stopped the $$anonymous$$oment I fade another animation in?
Blending is a completely separate process to the animation itself. It only has an effect on how the animation gets applied.
As stated by the documentation, CrossFade
Fades out all other animations, and fades that one in. That's why it seems it "suppresses" the other animations. I suggest a different layer
Answer by Benproductions1 · Jul 09, 2013 at 12:22 AM
Hello there,
Using animations from a long dead project (and a couple minutes of try/fail), I created a script that did exactly what you want to achieve.
The names are a bit different, but you can get the general idea ;)
It's also written in js, but you should have no problem following the logic
var hip:Transform;
function Start() {
animation["Run"].wrapMode = WrapMode.Loop;
animation["Run"].layer = 1;
animation.Play("Run");
animation["StandingAimDown"].wrapMode = WrapMode.ClampForever;
animation["StandingAimDown"].layer = 1000; //above anything else
animation["StandingAimDown"].AddMixingTransform(hip);
yield WaitForSeconds(3);
animation.Play("StandingAimDown");
}
This is tested and working.
Hope it helps,
Benproductions1
Your answer
Follow this Question
Related Questions
Animator Override Controller Layer Issue 1 Answer
Correct way to use mecanim and AddMixingTransform? 1 Answer
Issue with animation 1 Answer
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers