Knockback

Get help using Construct 2

Post » Sat Dec 15, 2012 2:06 am

Basically I want to make my character knock back when hit by an enemy so that you can't be hit in rapid succession. Something similar to this in Monster World 4:
http://youtu.be/BhKZXacyPTY?t=40s

I though I might be able to do it by simulating the platformer jump action but that only makes him jump straight up and also too high. For some reason when using simulate jump I can't change the jump strength or direction. Any Ideas?

Here is a link to my .capx, the blue square is the enemy. Arrows to move, space to jump:


http://www.mediafire.com/?wqqwekrrqv9g6rzJakten2012-12-15 02:50:47
B
5
Posts: 29
Reputation: 758

Post » Sun Dec 16, 2012 4:37 pm

Sorry to bump this but it's something that is really stumping me.
B
5
Posts: 29
Reputation: 758

Post » Tue Dec 18, 2012 8:18 pm

I'm having the same problem, and no one will answer me either. The best ive done is given the object physics behavior, and on collision, turn physics behavior on, and set force towards something (some value of x and y)   but this doesnt work very well for me because i can only get the character to knockback in one direction so far. I want it to knockback depending on where the player was hit
B
34
S
4
Posts: 408
Reputation: 3,275

Post » Tue Dec 18, 2012 8:25 pm

@bscarl88

When the knock back happens check the players X position against the enemies X position. If players X is less than enemies X do the knock back from the bottom right of player. If the enemies X is less than players X then do the knock back from bottom left of player.
B
44
S
13
G
7
Posts: 603
Reputation: 7,916

Post » Tue Dec 18, 2012 8:42 pm

[QUOTE=EncryptedCow] @bscarl88

When the knock back happens check the players X position against the enemies X position. If players X is less than enemies X do the knock back from the bottom right of player. If the enemies X is less than players X then do the knock back from bottom left of player.[/QUOTE]

hmmm great idea! I was wondering how I could do this with a 4 player fighting game.   I guess I would have to check all combinations of P1 vs P2, P2 vs P3, P1 vs P3 etc
B
34
S
4
Posts: 408
Reputation: 3,275

Post » Tue Dec 18, 2012 8:52 pm

You have to use "set platform vector".

I did something like this on my GGJ project earlier this year. It works, but if you want the player to be knocked back depending on the side on which he has been hit, you've got to add some things. This is also kind of a mess because I did it in a hurry.

Here's that bit of code:



Basically what's it saying is:


---

IF the player has been hit
AND he isn't invicible/blinking
AND the ducking animation isn't playing (he uses a shield when he's ducked)

Then

Deactivate the controls group
Set animation to hit
Set invicible var to 1 (which makes him blink and be invicible for a short period of time)
Set platform vector Y to -200 (this makes the player move up, if you want to increase/decrese the size just mess with the number, but it has to be negative for him to go up)
Subtract one from health

---

If you want to have him be knocked back instead of just up, you have to add the "set platform vector X" too.
B
114
S
38
G
40
Posts: 820
Reputation: 27,262

Post » Sat Dec 22, 2012 3:40 pm

Very nice!   Problem is though that he will only be knocked back in the Same direction no matter where he is hit.   
To fix that you could ether do what Encryptedcow said above , or add a condition saying
If player is not mirrored > set enemy platform vector x = 200.   
If player is mirrored > set enemy platform vector x = -200


I'll be using physics for my knockback though. So I'm in a different boat
B
34
S
4
Posts: 408
Reputation: 3,275


Return to How do I....?

Who is online

Users browsing this forum: mrline, newt and 10 guests