- Home /
animating character
hi guys
unity animation script is not working for me can someone help. when i attach this to my char nothing happens but when i remove it, it plays all of them at once. I need a script in which i can drop my animation files into and it can play it accordingly
function Update ()
{
if (Input.GetAxis("Vertical") > 0.2)
animation.CrossFade ("walk");
else
animation.CrossFade ("idle");
}
all help would be good. I had to spend several days to bring the animation in and now i am stuck at this
please help
Help me pls :
The script movoment me shows error :
The animation state FPSwalk could not be played because it couldn't be found! Please attach an animation clip with the name 'FPSwalk' or call this function only for existing animations. UnityEngine.Animation:CrossFade(String) movoment:Update() (at Assets/$$anonymous$$ojeScripty/movoment.js:5)
And: The AnimationClip 'FPSwalk' used by the Animation component 'lara vyfarbena' must be marked as Legacy. UnityEngine.Animation:CrossFade(String) movoment:Update() (at Assets/$$anonymous$$ojeScripty/movoment.js:5)
although me object in legacy
,
Answer by duck · Jun 04, 2010 at 10:07 AM
It's probably because you're repeatedly triggering the crossfade every frame, rather than just at the single moment when the animation should change.
You need to add some extra code which checks whether the input state has changed from what it was last frame, and only if it's changed, do the CrossFade. In the example below, a boolean variable (true/false) is used to check whether the state has already been changed.
Eg:
var walking = false;
function Update () { if (Input.GetAxis("Vertical") > 0.2 && !walking) { animation.CrossFade ("walk"); walking = true; }
if (Input.GetAxis("Vertical") <= 0.2 && walking) {
animation.CrossFade ("idle");
walking = false;
}
}
hi what if i want to add 2 attacks also whith this animation how would i do that like shoot and throw granade thanks
Your answer
Follow this Question
Related Questions
Unity3D AI using animations 1 Answer
animation script help 0 Answers
Simple Attack Script Problem 2 Answers
Unity animations not working 1 Answer
Check to see if animation is playing 1 Answer