- Home /
The question is answered, right answer was accepted
How to combine animations ?
Hello everyone !
I'm new at unity, but I already love it and intend to develop several things on it !
After a lot of tutorials on the internet, answers found in this forum (thanks for this huge community by the way :) ), I found myself in front of a big problem without finding any solutions : combining animations.
I started a multiplayer FPS. My character has several animations (walk, idle, jump, knife shot, ...). My problem is I want the character to walk when the up arrow is pressed (no problem for that), arms to move for a knife shot when fire1 is pressed (no problem again), BUT, the combination of the two of them il a problem. I tried several solutions, but nothing worked as i wanted :(
The problem is that my walk animation is looking good when i hit with the knife, but the knife shot animation is like "limited", the arm moves not as high as it should go, not as high as it goes if the character is not walking in the mean while... There is also a little glitch on the walk animation while the knife animation is playing but i think this is the same problem. There is some knid of interaction between the 2 animations.
At first the walk animation moved shoulders and feet and the knife animation was moving only shoulders. Then I removed the shoulders animation in the walk to not have interferences but it changes nothing. I'm sure it's an obvious solution and i'm missing something huge but I can't figure it out myself. Any suggestions ? Thanks for advance :)
This is the code (with only important ligns):
function Start () {
animation["knife"].layer=1;
animation["knife"].blendMode = AnimationBlendMode.Blend;
animation["walk"].blendMode = AnimationBlendMode.Blend;
}
function Update() {
if (Input.GetButtonDown("Fire1"))
{
Fire();
}
if (Input.GetKeyDown(KeyCode.UpArrow))
{
if (!animation.IsPlaying("walk"))
{
animation.CrossFade("walk");
}
}
}
function Fire() {
animation.CrossFade("knife");
}
Answer by Paulius-Liekis · May 08, 2012 at 02:52 PM
Look into AddMixingTransform function - it allows you to play one animation on lowerbody and other on upperbody.
This is good example project: http://unity3d.com/support/resources/example-projects/3rdpersonshooter
"Unite 09 - Character Animation tips and tricks" video talk describes techniques used in the example project: http://unity3d.com/unite/archive/2009
Welcome to Unity Answers!
Follow this Question
Related Questions
Multiple animations problem. 0 Answers
Exporting multiple animations from Blender 2 Answers
how to make one script with different animations attached 2 Answers
Can i do multiples scenes ? 2 Answers
Multiple animations in the same FBXfile? 9 Answers