Attack Combo Script [Finished]

For anyone that’s interested I finally got my attack combo script finished, here it is.

var LastPress : float;
var timer : float;
var Ctime : float = 1;
var tap : int;
var attack : boolean = true;
var Atime : float = 2;
var Aspeed : float = 2;

function Update(){

timer = Time.timeSinceLevelLoad;
if(Input.GetKeyDown("j")){
LastPress = Time.timeSinceLevelLoad;
if(tap > 2){
tap = 1;
}
else{
tap++;
}
Combo();
}
if(timer - LastPress > 1){
tap = 0;
if(timer - LastPress < Atime){
attack = false;
}
else{
attack = true;
}
}
}

function Combo () {
//WaitForSeconds(2);
if(attack){
switch (tap){

case 0:
//Reset to Idle
break;

case 1:
//Combo Start
Atime = animation["Attack1"].length;
animation.PlayQueued("Attack1", QueueMode.PlayNow);
break;

case 2:
//Combo Prolonged
Atime += animation["Attack2"].length;
animation.PlayQueued("Attack2", QueueMode.CompleteOthers);
break;

case 3:
//Combo Finished
Atime += animation["Attack3"].length;
animation.PlayQueued("Attack3", QueueMode.CompleteOthers);
break;
}
}
}

what do you mean combo attack? like make the mob/npc/player for example “target + use hook + bring target + cast spell/attack” ?

No not like that, it’s just a simple press “attack” multiple times to play attack animations in order, and if you don’t then it resets to the first animation.

If can be helpfull i used this statment to make play an animation after a key was pressed once, to play all the animation without interruptions:-
if( Input.GetButton(“Fire3”) || (animation.IsPlaying(“animation_name”) && animation[“animation_name”].time < animation[“animation_name”].length ){
animation.CrossFade(“animation_name”);
}

What happens when a player isn’t constantly attacking? Won’t the timer and LastPressed eventually become larger than Atime and make attack false?

Please Check

Basically it is cheat code system but supports attack combo system