GameMaker Studio 2: Melee Attacks Tutorial

▶ Source code:
▶ Support my work:

A remade, revamped and more in depth video on melee attacks for GameMaker Studio 2. Part 1 covers a basic attack using a state machine, part 2 will cover combo chains.

Shout outs to PixellatedPope and other members of the GameMaker subreddit discord channel for their help in making this video.

▶ Animation_end() script:
▶ State machines in depth:
▶ GameMaker Discord:


Xem thêm bài viết khác:

card trick 7 Black and red , 10s and 9s
Pocahontas Sega Mega Drive Genesis Complete Soundtrack OST Game Music
Shrek Forever After Walkthrough Part 1 (PS3, X360, Wii, PC) – Ogre Camp
  • So I have two different sprites, one for moving and one forstill with a sword, how do I code it so that those sprites only show up when I hit the button

  • My player just gets stuck in the air if i melle in air i suppose i could just do a check and only allow playerto attack on ground

  • can someone explain to me what the "hit by attack" list does?

  • How would I got about doing this in pygame?

  • I have this problem that all of my enemies is getting attacked when one is damaged is there another tutorial for the enemy scrips or?

  • KcazzKcazz

    Author Reply

    When I added this to my game the attack keeps triggering every frame, playing my attack sound multiple times and killing the enemies instantly.

  • What to use instead of instance_place_list? 18:12

  • i see you didn't use delta time when you added hspeed to x. is this something specific to gamemaker studio? or am I missing something about frame rates.

    thank you

  • Doesn't this method make the player invulnerable for multiple frames while attacking tho? maybe fine for some games but

  • Pls make DND tutorial…


  • Is possible to make a melee jump attack??

  • haha love this video good stuff. good stuff indeed.

  • This is literally exactly what I needed, and I wasn't even looking for this! Thank you!

  • What manual is he talking about @24:30?

  • Helpful tutorial. The only thing is the player will freeze if attacking in midair. I followed the code closely, but have to restrict the player to only being able to attack while on the ground (which works fine for the game I'm working on, but just saying)

  • Is there a tutorial available for the moving background?

  • how can i create a new enemy ? did i really have to create each time 3 new scripts for each enemy ?! like EnemyBlobState_Free / EnemyBlobState_Hit / EnemyBlobState_Dead and if i want to add some movement and attacks to my enemy i have to create EnemyBlobState_Move / EnemyBlobState_Attack ??

  • Hello friend, can you please help me with the automatic subtitles of this video? Do you remember ?, it is only deactivate and activate, without deleting. Thank you.

  • My character gets stuck in the air, Is there any solution??

  • When i press the button the slash animation never ends, even though i'm using the "animation_end" script.

  • i'm new to gamemaker and it doesn't work for me. probably because of someting in my preveous code that controdicts or messes something up

  • I went to this tutorial to learn how to set my character attack animation to happen and then go back to the normal sprite when it's done (since i'm doing a different combat style in my game) , i was planning to use the animation_end , but for some reason my gamemaker doesn't have this , so i tried the following

    sprite index = spr_player_attacking;
    image_speed = 1;
    if (image_index = 3)
    sprite_index = spr_player;

    But for some reason when i press 1 to attack , it only appears the first frame of the attacking animation , the animation only continues if my character keeps walking , what do i do ?

  • How do I change what direction the player is attacking in based on which direction they are facing? I can’t figure that part out. When I walk left and the attack animation faces right, it automatically attacks to the right. I duplicated and flipped the animation, now I just need to know how to program it to pick the right animation based on the direction

  • this might seem super simple, but i want to know, if i have more than one enemy, how do i reference it? you just put oEnemy in your hits variable, but what if you have multiple types? the parent enemy does work. i would really appreciate an answer

  • When you make the horizontal and vertical speed equal to 0 upon entering the slash player state, is that entirely necessary? It seems like it would allow for people to just spam the attack button and hover in midair, and I don’t see any consequences for not implementing it.

  • Can someone tell me when he shows off the EnemyHit Script? Or tell me where I can find it. Thank you.

  • wouldnt that make the play invincible while attacking because we redefined its hitbox?

  • hey there im facing problems with gms 2 it's whenever i press the Q button to attack i turn into a wall and i dont know what to do please help me

  • your player’s sword like kris's from the delta rune is only different colors

  • show us the enemys code

  • someone help
    I tried attacking in midair and my character is stuck on the first frame, falls super slowly, moves super fast horizontally, and once he reaches the ground, his jump is tiny.