How do I program a melee attack?

1 favourites
  • 9 posts
From the Asset Store
Zombie attack is a survival game, where you have 2 types of games: Killer and survival.
  • I'm trying to program a melee attack in my platformer that I'm working on, and I'm having the hardest time figuring out how to do it

  • Make a boolean "melee" on touch melee button set bollean on .

    Lets say you have 3 animation ,attack1 - attack2 - attack3.

    On finished attack1 and boolean is true play attack2 etc.on finished attack3 set boolean false.

  • I've followed what you've said, now I need to program a hitbox for it. I tried setting the game to destroying the enemy I've put together, but as I found out, it killed every last one in the level.

  • Try add an instance variable to your enemies.

    Player is playing attack animation, player is overlapping enemy and frame is equal to 0 subtract 1 from enemy.health.

    Enemy health is equal or less than 0 destroy enemy.

    It's not a bad idea to add a hit box.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, I managed to get it all working as intended. I appreciate the help.

  • BTW, how would I program a separate hitbox for the attack to hit without my character being forced to take contact damage?

  • If i understand you want your player to not get damaged if collide with enemies when he attack?

    You have to run to event when the enemies collide with your player and compare if player does not play attack animations.

    If you want to add a hitbox make an empty sprite and create it when the player attacks.

    So if player playing animation attack and frame is equal to "what ever" -> system create hitbox.

    Hitbox on collision with enemies -> destroy hitbox.

    Just notice if you have your player flipped or mirrored you have to specify the position of hitbox.

    And another advise , destroy your hitbox on animation attack end so your player do not carry it anymore.

  • USE A COMPARE DISTANCE VARIABLE FOR HERO AND ALL ENEMIES, IF ANY ENEMY IS NEAR OF 0 TO DISTANCE...USE A HIT. YOU CAN USE A MULTIPLICATOR OF DAMAGE X DISTANCE...MORE FAR MINUS DAMAGE.

  • Thanks, managed to get it to work.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)