- Home /
Question by
Serpentice · Sep 26, 2012 at 12:21 AM ·
animationanimationscrossfadelayering
Can someone help me with layering animations?
I've been messing with crossfading and layering animations and I cant seem to get the layering to work. A small example is with the following animations, reload, sprint, idle. My script is set up so when I let go of the sprint key my character will play the idle animation. When I try to reload it only does part of the animation. If I hold my reload key down it will work but I dont want to have to hold it down. Im not sure if my idle animation is interrupting it or what. Ive tried setting my reload to a higher layer but nothing seems to change. Can you help?
animation["Reload"].layer = 1;
animation["WIdle"].layer = 0;
function FixedUpdate() {
if(Input.GetKeyDown(KeyCode.R)){
GameObject.Find("Soldier").animation.CrossFade("Reload");
}
if(Input.GetKey(KeyCode.LeftShift)){
GameObject.Find("Soldier").animation.CrossFade("Sprint");
}
else { GameObject.Find("Soldier").animation.CrossFade("WIdle");
}
}
Comment