# How do I do player/enemy knockback?

Get help using Construct 2

### » Wed May 21, 2014 10:47 pm

I'm making a zelda, top down, 8 direction movement, type game.

I want the enemy to be knocked back when hit. And if possible, at the same angle that they were hit at.

You can see within the first 15 seconds, how whenever The Player hits an enemy with his sword they are knocked back a certain distance at a specific angle. ALSO when The player is hit, he is knocked back in the same manner.

I messed around using physics behavior and didn't have much luck. I also tried doing bullet movement and only turning on the bullet movement when struck for 0.3 sec at an angle of the sword swing. But I didn't get very far with that either.

Any help would be greatly appreciated! Thank you for your time!
B
3
Posts: 1
Reputation: 202

### » Thu May 22, 2014 12:01 am

I'm not the greatest at this but try this:
On collision with Enemy => Move Player at Angle Enemy.Angle Distance 50
Hope this helps!
B
38
S
14
G
3
Posts: 263
Reputation: 4,305

### » Tue May 27, 2014 5:03 pm

try to aply a vector x or y in the inverse direction of the collision

Animator, illustrator, concept artist, special effects for games.

[email protected]

http://f-fman.wix.com/portfolio-ffman22

http://ffman22.deviantart.com/

tutorials:

https://www.scirra.com/tutorials/950/dynamic-mini-map dynamic-mini-map tutorial

https://www.scirra.com/tutorials/9479/p ... ing-damage falling damage platform tutorial

B
63
S
19
G
4
Posts: 341
Reputation: 6,645

### » Wed Sep 28, 2016 6:04 am

I wish there was an inverse() function
B
4
Posts: 8
Reputation: 218

### » Wed Sep 28, 2016 6:44 am

https://www.dropbox.com/s/zqa1oylpr0hxw ... .capx?dl=0

A rough draft. You'll have a lot of tweaking to do with the angle of motion to get it to how you like. You may want to try using an imagepoint on the sword rather than the player origin to base your angle off of. Also the speed and acceleration (deceleration in this case) can be tweaked as well to get the type of motion you want. A more complicated formula will get you the rapid decay or "eased out" motion as used in Zelda.

@Tebbo - Angle=Angle+180 would be inverted angle, variable=constant-variable gives you invertable values. Unless you had something else in mind for inverse()?
B
60
S
30
G
131
Posts: 1,925
Reputation: 73,827