Hello all,
I’m not much of a scripter but I try. Right now I’m trying to figure out how to script animations. I have a very simple script here, The idle animation plays but I can’t get the attack animation to play. I’d love it if I could find a reference for this, as I know I’m going to have far more questions than the community is going to want to deal with, Thanks!
function Update () {
if (Input.GetButtonDown("Jump"))
animation.CrossFade("atk 1");
else
animation.CrossFade("idle");
}
You need to set up your layers.
See the Scripting Reference in my signature (or use Unity’s Help->Scripting Reference), do a search for animation, there’s some examples in there.
Basically in your Start function you set
animation["atk 1"].layer = 1;
animation["idle"].layer = 0;
Then atk 1 animation will have precedence and play over idle. You’ll need to set up atk 1 to use WrapMode.Once or otherwise stop it from playing at some point, also.
Okay! Thanks for the post, I’ll be sure to check it out!