- Home /
clicking and attacking different animations
hi
i am trying to make it so that eachtime i get input.mouse(0), it uses slash a and then the second time i click mouse it does slash b and the third time it does slash c, then the loop resets to slash a again(kind of like a hack and slash game type of attacking). its kinda of confusing i know and i know i havent shown my code , this is because i dont know where to start with this type of thing.
plz dont critisize, i m just a guy askin for some help. any suggestion help
Answer by Borgo · Jan 25, 2011 at 04:51 PM
var movement : int = 1;
function Update(){ If (Input.GetButtonDown("Fire1")){
if(movement==1){
animation.Play("Slash1");
}else
if(movement==2){
animation.Play("Slash2");
}else
if(movement==3){
animation.Play("Slash3");
}
if(movement==3){
movement=1;
}else{
movement+=1;
}
}
}
That's the way to do it, but you should always use an open range limit like: if(movement>=3) ins$$anonymous$$d of if(movement==3). Especially when you have your movement var public. You could set it to 4 and the value would increase and no animation would be played at all.
YES!!! i've been on the hunt for this fo a few days! thanks Borgo and Bunny83. works great for the simple task I had
Your answer
Follow this Question
Related Questions
How to play animation with one click 1 Answer
Activating state upon mouse click in mecanim 1 Answer
Selecting gameobjects in game, 3 Answers
Shoot A Raycast At A Specific Location? 1 Answer
Create gameobject object on click 1 Answer