How do I Enemy melee attack?

0 favourites
  • 10 posts
From the Asset Store
Moles Attack game assets for 2D whack a mole smash and hit action fun game.
  • I'm searching forums and videos but I just found ranged attack . How do I enemy melee attack ?

  • Detect if enemy is overlapping player and attack/play anim every x seconds?

  • Detect if enemy is overlapping player and attack/play anim every x seconds?

    Yea m trying this. But my char instantly dying . Like this.

    but if I do , enemy only one frame moves

  • Those events run every tick so too fast to see anything, move to every X seconds for deducting health variables. Animation you can also add to every X seconds so it plays on every attack.

  • Those events run every tick so too fast to see anything, move to every X seconds for deducting health variables. Animation you can also add to every X seconds so it plays on every attack.

    Thank u for interest . My char. don't die instantly but attack anim. still doesnt work . enemy goes in circles on my char .

  • You can try a line of sight maybe, if the player is close the enemy will play the melee attack. Something like 50 may do it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ya that is not the animation but more that the object is stuck and pushing on the player, you need to set a limit distance of x between enemy and player for the enemy to a. stop following and b. start attacking

  • Ya that is not the animation but more that the object is stuck and pushing on the player, you need to set a limit distance of x between enemy and player for the enemy to a. stop following and b. start attacking

    How I write this to the event sheet? I tried some things but didn't again :((

  • Depends how your enemy is moving :) what logic are you using to move, it is bullet moving left/right? When they attack you can set speed 0 or disable bullet, then if player moves away so distance between player and enemy is greater than 20 for example, then you set speed back to normal or enable bullet. Distance check is distance(player.x,player.y,enemy.x,enemy.y) > 20.

  • Depends how your enemy is moving :) what logic are you using to move, it is bullet moving left/right? When they attack you can set speed 0 or disable bullet, then if player moves away so distance between player and enemy is greater than 20 for example, then you set speed back to normal or enable bullet. Distance check is distance(player.x,player.y,enemy.x,enemy.y) > 20.

    I did like this and it worked . Thanks a ton :)

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