I need help to make a melee combo

N

N00BL1NK300

Guest
this code for some reason makes the character stop in the same animation of attack for the enterity of the time, i still haven´t implemanted a combo sistem, but i guess you could help me with that as well


if (key_attk = 1 && canAttack == 0) {// you can add a "blocker variable" to block the player attacking so fast like "&& canAttack = 1" and put "canAttack = 0;" in the code bracket under this line. And you set canAttack = 1 in Animation End Event to reset that

canAttack = 1
sprite_index = sprErikAttack1 //change this if you need
instance_create( (x+distancex), (y+distancey), objSword )
if(canAttack = 1) {
delay += 1
if(delay > 1) {
canAttack = 0
delay = 0
}
}
}
 
N

nlolotte

Guest
I personally would use an alarm or animation end event to finish attacking.

Create event:
Can_attack = 0;

Step event:
If attack_key && can_attack = 0
{
Sprite_index = spr_attack;
Can_attack = 1;
}

Animation end event:
If sprite_index = spr_attack
{
Sprite_index = spr_normal;
Can_attack = 0;
}

Things to consider:
You may wanna look into state machines as they handle tasks like this perfectly and would make a good base to add a combo system.

You also may need to use an alarm if your attack animation is only a couple of frames or if you want a longer delay.

Sorry for the poor formatting, I am currently on my mobile.
 
N

N00BL1NK300

Guest
I personally would use an alarm or animation end event to finish attacking.

Create event:
Can_attack = 0;

Step event:
If attack_key && can_attack = 0
{
Sprite_index = spr_attack;
Can_attack = 1;
}

Animation end event:
If sprite_index = spr_attack
{
Sprite_index = spr_normal;
Can_attack = 0;
}

Things to consider:
You may wanna look into state machines as they handle tasks like this perfectly and would make a good base to add a combo system.

You also may need to use an alarm if your attack animation is only a couple of frames or if you want a longer delay.

Sorry for the poor formatting, I am currently on my mobile.






thank you, it really helped, and i may have to take a look into state machines because my teacher didnt teached me that and if the character is moving he takes longer on the attack animation and even longer if he is moving in y axis
 
N

nlolotte

Guest
No problem, if you want the character stationary whilst attacking, add speed = 0 to attacking key pressed, then set it back to 1 or whatever afterwards.

Are you using studio 2?
 
N

N00BL1NK300

Guest
No problem, if you want the character stationary whilst attacking, add speed = 0 to attacking key pressed, then set it back to 1 or whatever afterwards.

Are you using studio 2?
no im using 1.4
 
Top