- Home /
Answer by drak0 · Aug 07, 2012 at 12:38 AM
In the Update() function you add something like this:
if (Input.GetAxis("Vertical") > 0.2F){
animation["walk"].speed = 1.0;
animation.CrossFade("walk");
}
else if (Input.GetAxis("Vertical") < -0.2F){
animation("walk").speed = -1.0;
animation.CrossFade("walk");
}
else{
animation.CrossFade("idle");
}
The normal speed of the playback is 1, so -1 will play the animation backwards.This happens when Input.GetAxis("Vertical") returns a negative value (so you are going backwards).Hope this helps.I don't use C# so pardon me if made a mistake.
Answer by RodrigoSeVeN · Aug 07, 2012 at 12:10 AM
I only work with javascript, but I'm sure it's simple enough to translate to C#.
I'll consider you have some condition to know when the enemy is not moving anymore. Besides that, I normally use this:
if(moving==false && !animation.IsPlaying("walk") && !animation.IsPlaying("idle")){
animation.Play("idle");
}
Your answer
Follow this Question
Related Questions
How would I go about making an animation affected by this script? 1 Answer
Enemy Animation Help 0 Answers
weapon destroyes enemy without running animation -1 Answers
Enemy animation help? 1 Answer
Easy Animation/Modeling question 2 Answers