How do I do this sequence?

0 favourites
  • 4 posts
  • I saw this game: https://www.instagram.com/p/BHehJ8ohmXK/ (Land of Fire by PixelComet)

    I was just wondering, how I can implement this sequence where if enemies are right next to or close to each other, an animation kicks in and hits enemies for combos.

    ps (sorry for the instagram link, only one i can find of said animation sequence).

  • The easiest way to do something like this would be to have an invisible "detector" or "helper" sprite that is around your character... Then if the player hits an enemy, and another enemy is within his "detector" then he will just move on to hit the next one.

    You would need to have some sort of Boolean instance variable to tell the player if an enemy has already been hit in the combo so he doesn't continuously hit the same enemy again and again... then the boolean could reset for each enemy after the player is no longer attacking.

    So your events would look something a little like;

    [For each enemy (loop)]

    [Player "attack" animation is playing]

    [Player "attack" animation is on last frame]

    [Enemy HasBeenHit.variable = 0]

    [Enemy is overlapping "detector"]

    --- Set player position X -> lerp(player.x,enemy,x-(player.width+enemy.width),1-0.3^dt)

    --- Set player position Y -> lerp(player.Y,enemy.Y,1-0.3^dt)

    --- Deal damage to enemy

    --- Set enemy.HasBeenHit.variable to 1

    --- Set player animation to "Attack" play from beginning

    This example would only work on an attack going left to right, but it should give you the rough idea to get something started.

    ~Sol

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • SoldjahBoy thank you! I actually started to try this and my algorithm is almost exactly like yours (except for the lerp parts). I'll definitely try to figure this out. Thanks again for your kind response!

  • No problem!

    ~Sol

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