• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Enemy Melee Attacks

W

WolfYouTube

Guest
I want to know how to do enemy melee attacks with a cool down effect
 
B

Blakkid489

Guest
Can you be a bit more specific? Like with animation, coding. . . .
 
M

molcap

Guest
Ok, so lets say there is an enemy. That enemy takes like 5 secs for the enemy hit again.
Set a variable to check if the player can attack (for example 0 is able to attack and 1 isn't), set an alarm and disable the attacks, in the alarm event set the variable again to 0.
Something like this:

create event

can_attack = 0

step

if keyboard_check(vk_space) and can_attack = 0
{
//attack
can_attack = 1
alarm[0] = 5*room_speed
}

alarm event

can_attack = 0
 
W

WolfYouTube

Guest
Set a variable to check if the player can attack (for example 0 is able to attack and 1 isn't), set an alarm and disable the attacks, in the alarm event set the variable again to 0.
Something like this:

create event

can_attack = 0

step

if keyboard_check(vk_space) and can_attack = 0
{
//attack
can_attack = 1
alarm[0] = 5*room_speed
}

alarm event

can_attack = 0
i don't want the player to attack only the enemy.
 
N

Noyemi K

Guest
You can repurpose molcap's code for pretty much any entity with an "attack" behaviour.
 
Top