# Enemy Pushing Away

Get help using Construct 2

### » Sat Jan 12, 2013 5:26 pm

Hello everyone.

I am making an overhead game, and I just got down the health bar and the player takes damage upon collision with another enemy. But what I would like to know, is how do I make the player be pushed back away from the enemy when coming into a collision with him.
B
6
Posts: 4
Reputation: 715

### » Sat Jan 12, 2013 6:50 pm

You will probably have to use the physics behaviour, although I think there might be a way without it but then again I'm not to sure how without physics.

Someone will probably give you better answer. But I guess the logic would be:

Event: if enemy is in collision with player
---> Action: enemy applies force to object(The Action is "Apply Force")

I'll see if I can make a capx with it later and get it working unless someone already does it.

[QUOTE=FallenWind] Hello everyone.

I am making an overhead game, and I just got down the health bar and the player takes damage upon collision with another enemy. But what I would like to know, is how do I make the player be pushed back away from the enemy when coming into a collision with him. [/QUOTE]
B
18
S
4
G
3
Posts: 436
Reputation: 4,801

### » Sat Jan 12, 2013 8:02 pm

Yeah you don't need physics for this :P Assuming you're using the 8 directional behavior..

Give your player a variable, lets name it "hurt".
When the player gets hit, set "hurt" to 10, set his deceleration to 100 or something else very low, set his angle of motion to the angle between himself and the enemy using angle() and finally set his speed to however fast you want him to be knocked back.

Now if that player variable is greater than 0 then subtract, say, 30*dt. When it's lower or equal to 0, activate your player event group and reset his deceleration.
B
223
S
26
G
13
Posts: 1,768
Reputation: 17,862

### » Tue Jan 15, 2013 1:21 am

Thanks a lot Tokinsom!
B
6
Posts: 4
Reputation: 715