- Home /
Character Looping Walk and Idle
Hi !! i ask something .. my character didn't walk continuously i cannot find the looping .. where i find it also the idle .. please .. help me .. Thank you so much .. for advance :)
Answer by MC HALO · Sep 03, 2011 at 04:21 AM
click on the animation in the project view and when you do that you will see settings for the animation and you can set it to loop from there :)
or if you want to loop a animation by script do the following:
function Start (){
Player.animation["DefaultAnim"].wrapMode = WrapMode.Loop;
}
this is how you set the animation to loop when the game starts. Now where it says "DefaultAnim" you need to look for you animations name and then put that there.
Now if you want to call an animation just do the following :
function Update (){
if(Input.GetKey(KeyCode.W)){
animation.CrossFade("DefaultAnim", 0.2);
}
else{
animation.CrossFade("Idle");
}
}
that is how you play an animation with the press of a key. basically all this does is it plays your animation when you press the W key when you let go it goes fading back into the Idle animation :)
hope this helps :)