- Home /
Multiple Animations, Please Help
I have a problem with this script. I want the player to attack when you click with the mouse, and then, continue with the idle animation. Help please?
function Update () { if(Input.GetMouseButtonDown(2)) { animation.CrossFade("Axe_Attack"); } else { animation.CrossFade("Axe_Idle"); } }
Answer by fafase · Oct 03, 2012 at 11:17 AM
function Update () {
if(Input.GetMouseButtonDown(2)&&!animation["Axe_Attack"].enabled){
animation.CrossFade("Axe_Attack");
}else if(!animation["Axe_Attack"].enabled ){
animation.CrossFade("Axe_Idle");
}
}
You will have to try as I cannot where I am. I would guess you do not want to be able to frenetically played the Axe_Attack, so you need to wait for it to be over to be able to play it again. If that is not what you want remove the !animation in the first occurance.
The else if checks if the Axe_attack is enabled so if not then the new animation is played. See if that goes.
Your answer
Follow this Question
Related Questions
How to stop Input? 1 Answer
Random attack animation 1 Answer
Castlevania style stop and attack script. 0 Answers
Play a simple animation once on key press 3 Answers
How do I destroy a game object when it is hit by a weapon? 3 Answers