How do I make a Damage Knockback system?

0 favourites
  • 6 posts
From the Asset Store
🙌 J-BoB Damage & Hit Sound Pack comes with 585 high-quality sound effects
  • Hello everybody.

    I'm reeeeally new to Construct 2 and I'm producing a platformer like Megaman using free internet stuff.

    So, I want to know how do I make the character go back a little when an enemy hits him (just like in Megaman). I managed to do it in a way, but it's not as dynamic as I want.

    This is the system I created. When the character (Jogador, I'm brazillian so it's all in portuguese) is overlapping at offset +1 pixel or -1 pixel he moves to opposite sides. But he just moves, he suddenly moves to the side, he doesn't "slide" dynamically to it.

    So, to be clear, I would love if someone could help me making a system in which the character, when hitting an enemy, do a little jump to the opposite side and stay in place for some miliseconds. Thank you

    drive.google.com/open

    This is the capx file. All the variables and objects are in Portuguese and the version is r229

  • My best guess is to go to a sprite animation editor and create an animation that make the character to feel like knock back and then do your variable and speed and placement.

    Best guess here is to use spriter pro there a free mode and you can basically just animate him going back and then once you are done.

    In the contruct there a great powerful tool call the slider. Now make two value 0-999 Next reference the pixel action that you wish to do and then create a textbox. Now I want you to do something like reference the pixel knock back variable to the value of the slider value so that you can dynamically change it in game without changing it in the event every 2 sec. and to make it visually easier to see the number is to set the text box to every tick - set text to the slider value.

    And this should give you a sort of a turning knob to see what pixel speed and animation would this look good but does well visually. I use this technique when i have a problem with speed and animation. dunno why there isnt a tutorial on this hint. but basically what you want depend on your eyes. but this is just my idea on how to help you out. i dunno what else i can think of

  • Wow, thank you for the hint. That makes a lot of sense.

    What action should I use to make the character go backwards? An action that wouldn't just set his position

  • I would just use the set player vector.x (- or +) the amount you want to push the player.

    I would use 'on collision' so it only triggers once, or the way you have it may work.

  • You can make him "slide" how you want if you move him using something like this:

    on collision with enemy -> set X position to lerp(current.x,current.x+10,1-0.2^dt) (or do -10 for the opposite way)

    ~Sol

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would just use the set player vector.x (- or +) the amount you want to push the player.

    I would use 'on collision' so it only triggers once, or the way you have it may work.

    Yes, my system actually works. I tried with set player vector x, but it does the same effect, the player is just teleported, he doesn't slide that way. Thanks for the response, I'll start usin the On Collision thingy, I actually didn't know the difference between that and overlapping, but now I know

    You can make him "slide" how you want if you move him using something like this:

    on collision with enemy -> set X position to lerp(current.x,current.x+10,1-0.2^dt) (or do -10 for the opposite way)

    ~Sol

    Oh Thank you. I have finished my project already, I have to deliver it on Saturday, but I'll start using this code on my future projects with Construct 2. Thank you very much

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