How do I make a Damage Knockback system?

Get help using Construct 2

Post » Sat Jun 18, 2016 7:44 pm

Message: marcosfl can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
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.

Image

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

https://drive.google.com/open?id=0B2yZXSPQBErnU05DOVBkZlpIUTQ

This is the capx file. All the variables and objects are in Portuguese and the version is r229
B
20
S
7
Posts: 24
Reputation: 1,422

Post » Sat Jun 18, 2016 8:54 pm

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
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Sun Jun 19, 2016 10:27 pm

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
B
20
S
7
Posts: 24
Reputation: 1,422

Post » Mon Jun 20, 2016 2:02 am

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.
B
22
S
12
G
19
Posts: 54
Reputation: 11,554

Post » Mon Jun 20, 2016 4:18 am

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
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Thu Jun 23, 2016 9:58 pm

evillair wrote: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 :D


SoldjahBoy wrote: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 :D
B
20
S
7
Posts: 24
Reputation: 1,422


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Lordshiva1948 and 14 guests